Open pimotte opened 5 years ago
Basically there are two issues using docker-compose. (on a VM <> ContainerInstance)
above example copies org.key and cert.key direct into the container(image) before it is pushed to docker-hub. This is not desired, i know.!
Disclaimer just try to set up a Kubernetes build pipeline LPC and ACI Container Instances
https://hub.docker.com/repository/docker/boscp08/waardepapieren_clerk-frontend https://hub.docker.com/repository/docker/boscp08/waardepapieren_waardepapieren-service https://hub.docker.com/repository/docker/boscp08/waardepapieren_mock-nlx
Pim Otte created Branch: feature/certs-as-environment-variables for this i will try to get this working tomorrow.
grep -ilr 'https://mock-nlx' | xargs -I@ sed -i '' 's/https:\/\/mock-nlx/https:\/\/zuidugchelen.eu/g' @ grep -ilr 'https://waardepapieren-service' | xargs -I@ sed -i '' 's/https:\/\/waardepapieren-service/https:\/\/zuidugchelen.eu/g' @
this works on https://zuidugchelen.eu / Don't change localhost to FQDN thismakes the application instable after some time. (after 5 till 30 minutes)
proces described in following youtube https://www.youtube.com/watch?v=5irsAdKoEBU&list=PLLasX02E8BPCrIhFrc_ZiINhbRkYMKdPT&index=6
by 18-12-2019 this was working on ACI today almost on LPC (self certificate issue is pending)
20200211 status update Below
https://gitlab.l12m.nl/logius/hack/ezahr/blob/master/.gitlab-ci.yml this pipeline shows the next possible and hopefully final steps.
https://github.com/discipl/waardepapieren/tree/feature/certs-as-environment-variables
with https://github.com/discipl/waardepapieren/blob/feature/certs-as-environment-variables/prepare-env.sh
2 scenario's here
2.1 tag image prefererred way, but needs additional deployment config
2.2 commit containers to new image. NB org.key and cert.keys are build in.
see below
Build / deploy
#
# GitLab Build Pipeline
#
# CI* and KUBE* variables are defined by GitLab Settings
#
#
image: docker:stable
stages:
- build
- deploy
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "" # Workaround for docker in docker failure 'Cannot connect to the Docker daemon'
REGISTRY_SERVER: "harbor-ot.l12m.nl"
REGISTRY_PROJECT: "hack"
IMAGE_NAME: "ezahr-service" # Change this
TAG: "0.2" # Fixed version for testing purposes by others
DOCKER_HOST: "tcp://localhost:2375"
CD_NAMESPACE: hack-ontwikkel
services:
- docker:dind
before_script:
- echo "Started by:${GITLAB_USER_LOGIN} with configuration:"
- echo CI_PIPELINE ${CI_PIPELINE}
- echo CI_COMMIT_SHA ${CI_COMMIT_SHA}
- echo TAG ${TAG}
- echo KUBE_URL ${KUBE_URL}
- echo REGISTRY_SERVER ${REGISTRY_SERVER}
- echo REGISTRY_PROJECT ${REGISTRY_PROJECT}
- echo IMAGE_NAME ${IMAGE_NAME}
- echo ROBOT_NAME ${HARBOR_ROBOT_NAME}
- echo ROBOT_SECRET ${HARBOR_ROBOT_SECRET}
- echo "Start $(date)"
after_script:
- echo "End $(date)"
build-image:
stage: build
script:
# Login to Registry > https://docs.gitlab.com/ee/user/project/deploy_tokens/index.html#gitlab-deploy-token
# Hide password > https://docs.docker.com/engine/reference/commandline/login/
- docker build -t "${REGISTRY_SERVER}/${REGISTRY_PROJECT}/${IMAGE_NAME}:${TAG}" --build-arg TAG="${CI_PIPELINE_ID}" --network=host . # Build latest; host network speeds-up remote retrievals
- echo -n "${HARBOR_ROBOT_SECRET}" | base64 -d | docker login -u ${HARBOR_ROBOT_NAME} --password-stdin ${REGISTRY_SERVER}
- docker push "${REGISTRY_SERVER}/${REGISTRY_PROJECT}/${IMAGE_NAME}:${TAG}"
deploy-ot2:
stage: deploy
environment: lpc-ot2
image: registry.gitlab.com/quattro-public/quattro-k8s-kubectl
dependencies: [] # Workaround > https://gitlab.com/gitlab-org/gitlab-ee/issues/6144
only:
- master
script:
# Deploy the pod in k8s
- kubectl config set-context $(kubectl config current-context) --namespace=${CD_NAMESPACE}
- kubectl apply -f ./k8s/deployment.yaml # Pod deployment
- kubectl apply -f ./k8s/service.yaml # service deployment
- kubectl apply -f ./k8s/ingress.yaml # ingress deployment
Example pull from harbor https://gitlab.l12m.nl/logius/hack/ezahr/blob/master/k8s/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: ezahr # Deployment name
spec:
replicas: 1
selector:
matchLabels:
app: ezahr
template:
metadata:
labels:
app: ezahr
ingress-frontoffice-policy: allow
spec:
containers:
- name: ezahr
image: harbor-ot.l12m.nl/hack/ezahr-service:0.2
imagePullPolicy: Always
ports:
- containerPort: 8888
resources:
requests:
memory: 50Mi # 50 Megabytes
cpu: 100m # 1 CPU = 1000 > 300m is 300/1000 = 10% CPU
limits:
memory: 50Mi
cpu: 100m
imagePullSecrets: # https://kubernetes.io/docs/concepts/configuration/secret/#using-imagepullsecrets
- name: harbor-puller
Network proxy issue ahead ... (pim to the rescue)
https://waardepapieren.hack-ontwikkel.lpc-ot2.l12m.nl/ -> renders 503 Service Temporarily Unavailable nginx/1.17.8 NB this is ingress from LPC not clerkfrontend - 1.15
I proceed with above approach.
hope the run will be okay
macos-cat:waardepapieren boscp08$ . bfg.bash mm 4 waardepapieren.hack-ontwikkel.lpc-ot2.l12m.nl
install
container brings itś own file system, on every type of system
sudo install -y docker docker-common docker-client
systemctl enable docker
systemctl start docker
docker run hello-world
docker configuration
but now as a 'normal' user
groupadd docker
usermod -aG docker boscp08
systemctl restart docker
docker run hello-world
hello from docker This message shows that your installation appears to be working correctly.
cleanup docker images and containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q) && docker rmi $(docker images -q)
docker container prune
docker stats --no-stream
get docker-cleanup.bash
curl -o cleanup.bash https://raw.githubusercontent.com/boschpeter/my-simple-pipeline/master/cleanup.bash
git clone master branch
git clone https://github.com/discipl/waardepapieren.git
get bfg.bash
curl -o bfg.bash https://raw.githubusercontent.com/boschpeter/waardepapieren/master/bfg.bash
FQDN setter https://waardepapieren.hack-ontwikkel.lpc-ot2.l12m.nl
ezahr LPC
sudo nano etc/hosts
/Users/boscp08/waardepapieren/docker-compose-travis yml
/Users/boscp08/waardepapieren/mock-nlx/Dockerfile
/Users/boscp08/waardepapieren/clerk-frontend/Dockerfile
/Users/boscp08/waardepapieren/waardepapieren-service/Dockerfile
/Users/boscp08/waardepapieren/clerk-frontend/nginx/nginx conf
/Users/boscp08/waardepapieren/waardepapieren-service/configuration/config-compose-travis.json
/Users/boscp08/waardepapieren/waardepapieren-service/configuration/waardepapieren-config-compose.json
/Users/boscp08/waardepapieren/waardepapieren-service/configuration/waardepapieren-config.json
docker-compose -f docker-compose-travis.yml up. 15'
docker commit tag and push 4.0
docker login
docker commit
docker images
docker push
Toegang tot logius Private Cloud
kubelogin
kubectl cluster-info -n hack-ontwikkel
kubectl apply -f ./k8s/deployment.yaml
deployment.yaml
git clone https://gitlab.l12m.nl/logius/hack/ictu-waardepapieren
https://waardepapieren.hack-ontwikkel.lpc-ot2.l12m.nl https://ezahr.hack-ontwikkel.lpc-ot2.l12m.nl
kubectl get events -n hack-ontwikkel
azure deploy