|
| 1 | +#Steps for using keel |
| 2 | + |
| 3 | +1. Make changes in baseservices.yaml as shown below. Add annotations section after namespace |
| 4 | +2. To select the custom tag (latest/dev/prod) or any tag that you provide during deploying services |
| 5 | +$keel.sh/policy: glob:{{build_id}} |
| 6 | +3. The method that keel will use to check image updates. here we are using polling method. |
| 7 | +$keel.sh/trigger: poll |
| 8 | +4. Time span that keel will poll the private registry. |
| 9 | +$keel.sh/pollSchedule: "@every 30s" |
| 10 | +5. In containers section change image pull policy to Always, this will Always pull image from registry whenever a change is detected. |
| 11 | +$imagePullPolicy: Always |
| 12 | +6. Add Image pull secrets section and provide the secret name that you will be creating. here raven-registry is our secret name. |
| 13 | +$imagePullSecrets: |
| 14 | +$- name: raven-registry |
| 15 | +7. I have demonstrated the changes in event-app service example. |
| 16 | + |
| 17 | +apiVersion: apps/v1 |
| 18 | +kind: Deployment |
| 19 | +metadata: |
| 20 | + name: event-app |
| 21 | + namespace: default |
| 22 | + labels: |
| 23 | + name: "event-app" |
| 24 | + annotations: |
| 25 | + keel.sh/policy: glob:{{build_id}} |
| 26 | + keel.sh/trigger: poll |
| 27 | + keel.sh/pollSchedule: "@every 30s" |
| 28 | +spec: |
| 29 | + selector: |
| 30 | + matchLabels: |
| 31 | + app: event-app |
| 32 | + replicas: 1 |
| 33 | + template: |
| 34 | + metadata: |
| 35 | + labels: |
| 36 | + app: event-app |
| 37 | + spec: |
| 38 | + containers: |
| 39 | + - name: event-app |
| 40 | + image: {{registry_server}}/{{client_name}}/event-app:{{build_id}} |
| 41 | + imagePullPolicy: Always |
| 42 | + volumeMounts: |
| 43 | + - mountPath: /app/images |
| 44 | + name: glusterfs |
| 45 | + - mountPath: /app/config |
| 46 | + name: config |
| 47 | + - mountPath: /app/k8s |
| 48 | + name: kubeconfig |
| 49 | + - mountPath: /app/raven-cam |
| 50 | + name: ravenyaml |
| 51 | + - mountPath: /app/ffmpeg-cam |
| 52 | + name: ffmpegyaml |
| 53 | + volumes: |
| 54 | + - name: glusterfs |
| 55 | + hostPath: |
| 56 | + path: /mnt/ravenfs/pivotchain |
| 57 | + type: Directory |
| 58 | + - name: config |
| 59 | + configMap: |
| 60 | + name: backend-config |
| 61 | + - name: kubeconfig |
| 62 | + configMap: |
| 63 | + name: kubeconfig |
| 64 | + - name: ravenyaml |
| 65 | + configMap: |
| 66 | + name: raven-yaml |
| 67 | + - name: ffmpegyaml |
| 68 | + configMap: |
| 69 | + name: ffmpeg-yaml |
| 70 | + imagePullSecrets: |
| 71 | + - name: raven-registry |
| 72 | + |
| 73 | + |
| 74 | +8. Setup the K8S cluster and then apply the keel-service.yaml which is present in yamls directory. |
| 75 | +If the keel-service.yaml is not present then apply below command |
| 76 | +$kubectl apply -f https://sunstone.dev/keel?namespace=keel&username=admin&password=admin&tag=latest |
| 77 | + |
| 78 | +This command will deploy Keel to keel namespace with enabled basic authentication and admin dashboard. |
| 79 | + |
| 80 | +9. To check whether Keel successfully started - check pods: |
| 81 | + |
| 82 | +$kubectl -n keel get pods |
| 83 | + |
| 84 | +You should see output something like this: |
| 85 | +NAME READY STATUS RESTARTS AGE |
| 86 | +keel-2732121452-k7sjc 1/1 Running 0 14s |
| 87 | + |
| 88 | +10. Do docker login to your registry |
| 89 | +$docker login $registry_server -u="$registry_user" -p="$registry_pass" |
| 90 | + |
| 91 | +11. Create secrets as Keel needs secrets to access private registry |
| 92 | +$kubectl create secret generic raven-registry --from-file=.dockerconfigjson=/root/.docker/config.json --type=kubernetes.io/dockerconfigjson |
| 93 | +To check if secrets are generated shoot below command |
| 94 | +$kubectl get secrets |
| 95 | +You should see output something like this: |
| 96 | +NAME READY STATUS RESTARTS AGE |
| 97 | +raven-registry 1/1 Running 0 36s |
| 98 | + |
| 99 | +12. Congratulations on implementing your keel. For any queries you can contact me at [email protected] |
0 commit comments