deploy/ Configuration Development¶
To configure a working deployment it's easiest to create and test on a local cluster (minikube, Rancher Desktop, etc...). This means you will need to be able to pull your app's image from a private registry.
Requirements¶
Download and install the following:
- kubectl-cli
- kustomize
- Docker
- a local cluster tool (minikube, k3s, Rancher Desktop, etc...)
Configure an ImagePullSecret in kustomization.yaml¶
With a local cluster up and running, start by getting the latest overlay working:
-
Set your GitLab username, password, and email
export USER="{yourUsername}" PASSWORD="{yourBCITpassword}" EMAIL="{yourBCITemail}" -
Create an
${AUTH_TOKEN}token:export AUTH_TOKEN=$(printf "${USER}:${PASSWORD}" | base64) -
Set a target environment:
export TARGET_ENV=latest -
Create a
.dockerconfigjsonin the secrets path:cat <<EOF > overlays/${TARGET_ENV}/secrets/.dockerconfigjson { "auths": { "https://registry.ltc.bcit.ca": { "username": "${USER}", "password": "${PASSWORD}", "email": "${EMAIL}", "auth": "${AUTH_TOKEN}" } } } EOF -
Uncomment the following sections in the
kustomization.yaml:secretGenerator: ... # - name: gitlab-registry-credentials # type: kubernetes.io/dockerconfigjson # files: # - .dockerconfigjson=secrets/.dockerconfigjson patches: ... # - target: # kind: Deployment # patch: |- # - op: add # path: /spec/template/spec/imagePullSecrets # value: [name: gitlab-registry-credentials] -
Create a fake
tls.crtandtls.keyecho "fake key" > overlays/${TARGET_ENV}/secrets/tls.key \ && echo "fake cert" > overlays/${TARGET_ENV}/secrets/tls.crt -
Confirm the kustomization renders correctly:
kustomize build overlays/${TARGET_ENV} -
Confirm your Kubernetes context (should match your local kubernetes cluster)
kubectl config get-contexts -
Add a namespace
kubectl create ns {yourProjectName} -
Attempt to apply the resources to the cluster:
kustomize build overlays/${TARGET_ENV} | kubectl apply -f - -
Unset sensitive variables
unset \ USERNAME={yourUsername} \ PASSWORD={yourBCITpassword} \ EMAIL={yourBCITemail} \ AUTH_TOKEN
If the resources generate an error, destroy them, adjust the manifests, and try again.