Search code examples
kubernetesdockerhubcontinuous-delivery

How to automatically deploy new image to k8s cluster as it was pushed to docker registry?


I have configured dockerhub to build a new image with tags latest and dev-<version> as new tag <version> is appeared in GitHub. I have no idea how to configure Tekton or any other cloud-native tool to automatically deploy new images as they become available at the registry.

Here's my k8s configuration:

apiVersion: v1
kind: List
items:
  - apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: my-app-ingress
    spec:
      rules:
        - http:
            paths:
              - path: /
                pathType: Prefix
                backend:
                  service:
                    name: my-app-service
                    port:
                      number: 80
  - apiVersion: v1
    kind: Service
    metadata:
      name: my-app-service
    spec:
      ports:
        - port: 80
          targetPort: 8000
      selector:
        app: my-app
      type: LoadBalancer

  - apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: my-app-local-deployment
      labels:
        app: my-app
        type: web
    spec:
      replicas: 2
      minReadySeconds: 15
      strategy:
        type: RollingUpdate
        rollingUpdate:
          maxUnavailable: 25%
          maxSurge: 1
      selector:
        matchLabels:
          app: my-app
      template:
        metadata:
          labels:
            app: my-app
        spec:
          imagePullSecrets:
            - name: regcred
          containers:
            - name: backend
              image: zuber93/my-app:dev-latest
              imagePullPolicy: IfNotPresent
              envFrom:
                - secretRef:
                    name: my-app-local-secret
              ports:
                - containerPort: 8000
              readinessProbe:
                httpGet:
                  path: /flvby
                  port: 8000
                initialDelaySeconds: 10
                periodSeconds: 5
            - name: celery
              image: zuber93/my-app:dev-latest
              imagePullPolicy: IfNotPresent
              workingDir: /code
              command: [ "/code/run/celery.sh" ]
              envFrom:
                - secretRef:
                    name: my-app-local-secret
            - name: redis
              image: redis:latest
              imagePullPolicy: IfNotPresent

Solution

  • Finally, I've explored keel.sh. It can handle appearing of new images and deploy them into the cluster.