Kubernetes workload controller for container image deployment

kube-image-deployer

kube-image-deployer는 Docker Registry의 Image:Tag를 감시하는 Kubernetes Controller입니다.

Keel과 유사하지만 단일 태그만 감시하며 더 간결하게 동작합니다.

Container, InitContainer를 모두 감시합니다.

현재 지원되는 Workload는 다음과 같습니다.

  • deployment
  • statefulset
  • daemonset
  • cronjob

Available Environment Flags

kubeconfig               = *flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
offDeployments           = *flag.Bool("off-deployments", false, "disable deployments")
offStatefulsets          = *flag.Bool("off-statefulsets", false, "disable statefulsets")
offDaemonsets            = *flag.Bool("off-daemonsets", false, "disable daemonsets")
offCronjobs              = *flag.Bool("off-cronjobs", false, "disable cronjobs")
imageStringCacheTTLSec   = *flag.Uint("image-hash-cache-ttl-sec", 60, "image hash cache TTL in seconds")
imageCheckIntervalSec    = *flag.Uint("image-check-interval-sec", 10, "image check interval in seconds")
controllerWatchKey       = *flag.String("controller-watch-key", "kube-image-deployer", "controller watch key")
controllerWatchNamespace = *flag.String("controller-watch-namespace", "", "controller watch namespace. If empty, watch all namespaces")

동작 방식

  • kube-image-deployer label을 가진 Workload를 감시 대상으로 등록 합니다.
  • Workload의 annotation을 읽어 감시할 Image와 Container를 매핑합니다.
  • 1분 간격(imageStringCacheTTLSec)으로 Docker Registry API v2로 이미지 정보와 이미지의 Digest Hash를 획득해 해당 사용중인 Workload의 Container에 Strategic Merge Patch를 진행합니다.
  • Image Digest Hash로 패치하기 때문에 새 태그만 추가되고 이미지 Hash가 변경되지 않은 경우는 Workload가 재배포 되지 않습니다. (의도됨)

Kubernetes Yaml Examples

Yaml 필수 구성 요소

  • metadata.label.kube-image-deployer
    • label을 가진 Workload를 감시하게 되므로 필수입니다.
  • metadata.annotations.kube-image-deployer/${containerName} = ${ImageURL}:${Tag}
    • 자동 업데이트를 동작시킬 컨테이너 이름과 이미지, 태그를 Annotation에 등록합니다.

Tag 감시 방식

  • Exact match tag

    • busybox:1.34.0 -> busybox@sha256:15f840677a5e245d9ea199eb9b026b1539208a5183621dced7b469f6aa678115
  • Asterisk match tag

    • busybox:1.34.* -> 1.34.0, 1.34.1, 1.34.2, ... -> busybox@sha256:15f840677a5e245d9ea199eb9b026b1539208a5183621dced7b469f6aa678115

Yaml Samples

Deployments

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kube-image-deployer/busybox-init: 'busybox:latest' # set init container update
    kube-image-deployer/busybox2: 'busybox:1.34.*'     # set container update
  labels:
    app: kube-image-deployer-test
    kube-image-deployer: 'true'                        # enable kube-image-deployer
  name: kube-image-deployer-test
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kube-image-deployer-test
  template:
    metadata:
      labels:
        app: kube-image-deployer-test
    spec:
      containers:
        - name: busybox
          image: busybox # no change
          args: ['sleep', '1000000']
        - name: busybox2
          image: busybox # change to busybox@sha:b862520da7361ea093806d292ce355188ae83f21e8e3b2a3ce4dbdba0a230f83
          args: ['sleep', '1000000']
      initContainers:
        - name: busybox-init
          image: busybox # change to busybox@sha:b862520da7361ea093806d292ce355188ae83f21e8e3b2a3ce4dbdba0a230f83

Private Repositories

kube-image-deployer는 Docker Creds로 기본 접근 권한을 획득합니다.

DockerHub / Harbor의 Private Registry 이미지 감시하기

  1. Kubernetes에 Private Registry 접근용 dockerconfig Secret을 생성합니다.
  2. Auths에 URL과 접근 방법(username/password...) 입력합니다.
  3. /root/.docker/config.json 위치에 Secret Volume을 마운트합니다.
  4. kube-image-deployer는 AuthKeyChain을 통해 Creds에 마운트된 정보로 Private Registry를 접근합니다.

ECR의 Private Registry 이미지 감시하기

두 가지 방법이 있습니다.

  1. kube-image-deployer Service Account에 ECR 접근 권한을 가진 Role을 설정해 권한을 주는 방법 (AWS IRSA)
  2. kube-image-deployer env에 ECR 접근 가능한 AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY를 입력하는 방법 (AWS AccessToken)

ECR 이미지 URL이 감지대상인 경우 kube-image-deloyer는 ECR의 GetAuthorizationToken을 호출해 Docker Auth Token을 획득하고 이 토큰을 사용해 Docker Registry API v2로 이미지 정보를 획득합니다.

Todo

  • Add Test Code
  • Support ECR Private Registry
Owner
PUBG Corporation
The official PUBG Corporation Github
PUBG Corporation
Similar Resources

Access your Kubernetes Deployment over the Internet

Access your Kubernetes Deployment over the Internet

Kubexpose: Access your Kubernetes Deployment over the Internet Kubexpose makes it easy to access a Kubernetes Deployment over a public URL. It's a Kub

Dec 5, 2022

Pega-deploy - Pega deployment on Kubernetes

Pega deployment on Kubernetes This project provides Helm charts and basic exampl

Jan 30, 2022

Kubernetes Operator to automate Helm, DaemonSet, StatefulSet & Deployment updates

Kubernetes Operator to automate Helm, DaemonSet, StatefulSet & Deployment updates

Keel - automated Kubernetes deployments for the rest of us Website https://keel.sh Slack - kubernetes.slack.com look for channel #keel Keel is a tool

Dec 28, 2022

KEDA is a Kubernetes-based Event Driven Autoscaling component. It provides event driven scale for any container running in Kubernetes

 KEDA is a Kubernetes-based Event Driven Autoscaling component. It provides event driven scale for any container running in Kubernetes

Kubernetes-based Event Driven Autoscaling KEDA allows for fine-grained autoscaling (including to/from zero) for event driven Kubernetes workloads. KED

Jan 7, 2023

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.

Jan 5, 2023

Reconstruct Open API Specifications from real-time workload traffic seamlessly

Reconstruct Open API Specifications from real-time workload traffic seamlessly

Reconstruct Open API Specifications from real-time workload traffic seamlessly: Capture all API traffic in an existing environment using a service-mes

Jan 1, 2023

Fleex allows you to create multiple VPS on cloud providers and use them to distribute your workload.

Fleex allows you to create multiple VPS on cloud providers and use them to distribute your workload.

Fleex allows you to create multiple VPS on cloud providers and use them to distribute your workload. Run tools like masscan, puredns, ffuf, httpx or a

Dec 31, 2022

SionReplayer is the workload replayer for SION project.

SionReplayer SionReplayer is the workload replayer for SION project. Simulation A sample of IBM docker registry trace is included. To run the simulati

Jan 13, 2022

Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

The Moby Project Moby is an open-source project created by Docker to enable and accelerate software containerization. It provides a "Lego set" of tool

Jan 8, 2023
Comments
  • image tag pattern 개선

    image tag pattern 개선

    Asterisk match tag에 여러 Asterisk를 쓸 수 있게 개선하면 좋을 것 같음

    예> sample:v1.1.3, sample:v1.1.4, sample:v2.10.1, sample:v2.2.0 형태의 태그가 있다고 할 때, sample:v*.*.* 패턴으로

    Asterisk index에 대치 되는 number 끼리 비교해 가장 높은 수의 태그로 업데이트 하면 됨

    sample:v2.10.1 = 2, 10, 1 sample:v2.2.0 = 2, 2, 0 = 2 vs 2 = 10 vs 2 = v2.10.1 win

  • remove unnecessary mutex

    remove unnecessary mutex

    다음 사항을 수정했습니다.

    • ImageUpdateNotifymutex 제거
    • ImageUpdateNotifyreferenceCount를 atomic으로 증감하도록 수정
    • checkList 함수의 checkList 변수명 변경

    mutex가 없어도 되는 이유는 다음과 같습니다.

    • ImageUpdateNotify의 state 는 referenceCount를 제외하고 변하지 않음
    • ImageNotifierlist에 접근 시 별도로 lock을 잡기 때문에 문제가 없음
A Controller written in kubernetes sample-controller style which watches a custom resource named Bookstore

bookstore-sample-controller A Controller written in kubernetes sample-controller style which watches a custom resource named Bookstore. A resource cre

Jan 20, 2022
expose controller, when deployment created service and ingress will be created

expose-controller expose controller, when deployment created service and ingress will be created How to test git clone repository cd expose-controller

Dec 23, 2021
Kubernetes controller for backing up public container images to our own registry repository

image-clone-controller Kubernetes controller which watches applications (Deployment and DaemonSet) and "caches" the images (public container images) b

Aug 28, 2022
provider-kubernetes is a Crossplane Provider that enables deployment and management of arbitrary Kubernetes objects on clusters

provider-kubernetes provider-kubernetes is a Crossplane Provider that enables deployment and management of arbitrary Kubernetes objects on clusters ty

Dec 14, 2022
A batch scheduler of kubernetes for high performance workload, e.g. AI/ML, BigData, HPC
A batch scheduler of kubernetes for high performance workload, e.g. AI/ML, BigData, HPC

kube-batch kube-batch is a batch scheduler for Kubernetes, providing mechanisms for applications which would like to run batch jobs leveraging Kuberne

Jan 6, 2023
network-node-manager is a kubernetes controller that controls the network configuration of a node to resolve network issues of kubernetes.
network-node-manager is a kubernetes controller that controls the network configuration of a node to resolve network issues of kubernetes.

Network Node Manager network-node-manager is a kubernetes controller that controls the network configuration of a node to resolve network issues of ku

Dec 18, 2022
Carrier is a Kubernetes controller for running and scaling game servers on Kubernetes.
Carrier is a Kubernetes controller for running and scaling game servers on Kubernetes.

Carrier is a Kubernetes controller for running and scaling game servers on Kubernetes. This project is inspired by agones. Introduction Genera

Nov 25, 2022
Kubernetes Operator for a Cloud-Native OpenVPN Deployment.

Meerkat is a Kubernetes Operator that facilitates the deployment of OpenVPN in a Kubernetes cluster. By leveraging Hashicorp Vault, Meerkat securely manages the underlying PKI.

Jan 4, 2023
Simple CLI tool and Kubernetes deployment.

Simple Application A basic example of how to build a naml project. app.go Every project should define an app.go file. The file should implement the De

Dec 21, 2022