This document explains how to start a mock server for the CI environment to test CoHDI.
In this procedure, you will work in a directory named mock, created directly under your home directory.
mkdir -p ~/mockcd ~/mock
git clone <URL of the Mock repository>
ls ~/mockThe structure should be as follows:
Dockerfile LICENSE Makefile Readme.md app.py config requirements.txt
This step generates a server certificate and private key for HTTPS communication with the mock server.
mkdir -p ~/mock/certs
cd ~/mock/certsvi openssl.cnfEnter the following content:
[ req ]
default_bits = 2048
prompt = no
default_md = sha256
distinguished_name = dn
[ dn ]
C = Default Country
L = Default City
O = Default Company Ltd
CN = cdimgr.localdomain
[ v3_ca ]
basicConstraints = critical, CA:true
keyUsage = critical, keyCertSign, cRLSign
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
[ v3_req ]
basicConstraints = CA:FALSE
keyUsage = critical, digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth, clientAuthopenssl req -x509 -newkey rsa:2048 -days 365 -keyout ca.key -out ca.crt -config openssl.cnf -extensions v3_ca -nodesopenssl req -new -nodes -newkey rsa:2048 -keyout server.key -out server.csr -config openssl.cnf -extensions v3_reqopenssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 3650 -sha256 -extensions v3_req -extfile openssl.cnfls ~/mock/certsThe structure should be as follows:
ca.crt ca.key ca.srl openssl.cnf server.crt server.csr server.key
cd ~/mock
makeAfter executing the command, a container image named mock_cohdi:test will be created.
docker images | grep mock_cohdiThe output should be as follows:
mock_cohdi test <image UUID> 23 hours ago 133MB
Start a container named mock_cohdi:test.
Here's an example for launching it using Kubernetes (includes pod and service definitions).
When Kubernetes uses containerd as its runtime, you cannot directly use images built with Docker.
In that case, please import the image into containerd using the following commands:
docker save mock_cohdi:test -o mock_cohdi.tar
sudo ctr -n k8s.io images import mock_cohdi.tarAfter running the above commands, verify that the image has been imported successfully with:
sudo crictl images | grep mock_cohdiThe output should be as follows:
docker.io/library/mock_cohdi test <image UUID> 206MB
apiVersion: v1
kind: Pod
metadata:
name: mock-server
labels:
app: mock-server
spec:
containers:
- name: mock-server
image: mock_cohdi:test
ports:
- containerPort: 443
---
apiVersion: v1
kind: Service
metadata:
name: mock-server
spec:
selector:
app: mock-server
type: ClusterIP
ports:
- protocol: TCP
port: 443
targetPort: 443kubectl apply -f mock-server.yamlkubectl get pods -A | grep mockIf the status is Running, the pod has successfully launched.
Please refer to the Helm-based installation method: https://github.com/CoHDI/cohdi-chart
In the CoHDI configuration, please set the parameters for the CDI management software's ENDPOINT and certificate to point to the mock server's IP address and certificate.