Menu

Tree [f697ca] add-code-of-conduct-1 /
 History

HTTPS access


File Date Author Commit
 artifacts 2021-01-21 renugadevi-2613 renugadevi-2613 [a8df3f] adding the deployment artificats
 controller 2021-01-21 renugadevi-2613 renugadevi-2613 [07b05b] Added CRD and Controller for Custom ConfigMap a...
 hack 2021-01-21 renugadevi-2613 renugadevi-2613 [07b05b] Added CRD and Controller for Custom ConfigMap a...
 labelconfig 2021-01-21 renugadevi-2613 renugadevi-2613 [07b05b] Added CRD and Controller for Custom ConfigMap a...
 pkg 2021-01-21 renugadevi-2613 renugadevi-2613 [07b05b] Added CRD and Controller for Custom ConfigMap a...
 watcher 2021-01-21 renugadevi-2613 renugadevi-2613 [07b05b] Added CRD and Controller for Custom ConfigMap a...
 .gitignore 2021-01-21 renugadevi-2613 renugadevi-2613 [a8df3f] adding the deployment artificats
 CODE_OF_CONDUCT.md 2021-01-21 gopaddle gopaddle [f697ca] Create CODE_OF_CONDUCT.md
 LICENSE 2020-11-11 gopaddle gopaddle [d136dc] Initial commit
 README.md 2020-11-18 gopaddle gopaddle [7d9e5c] Added AllDayDevOps video introduction
 configurator 2021-01-21 renugadevi-2613 renugadevi-2613 [07b05b] Added CRD and Controller for Custom ConfigMap a...
 go.mod 2021-01-21 renugadevi-2613 renugadevi-2613 [07b05b] Added CRD and Controller for Custom ConfigMap a...
 go.sum 2021-01-21 renugadevi-2613 renugadevi-2613 [07b05b] Added CRD and Controller for Custom ConfigMap a...
 main.go 2021-01-21 renugadevi-2613 renugadevi-2613 [07b05b] Added CRD and Controller for Custom ConfigMap a...

Read Me

Configurator

Configurator is a sync service that keeps Kubernetes deployments in sync with the ConfigMap updates.

When used with kustomize,
- Resource postfix as way to version control ConfigMaps
- Automatically triggers a rolling update on deployments referring to a configMap version
- Periodically purges unused ConfigMap versions

Supported Versions

  • K8s 1.16

Dependencies

Install kustomize in the Kuberentes client environment from where configMap creation needs to be triggered.
- kustomize

Building Configurator

Build the source code

dep ensure
go build main.go

How to use ?

Once configurator is compiled, start the service.

./main ~/.kube/config
curl -X POST -d '{"labels":[{"nameSpace":"default","configMap":"my-java"}]}' http://localhost:8050/api/watcher

Use kustomize to create or update configMaps. Say kustmization.yaml file must look like this. Note that the labels under option section must contain name=<configmapname></configmapname>

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
# These labels are added to all configmaps and secrets.
configMapGenerator:
- name: my-java
  behavior: create
  literals:
  - JAVA_TOOL_OPTIONS=-agentlib:hprof
  - JAVA_TEST=javatest
  - JAVA_HOME=/home/vino/addo
  options:
    disableNameSuffixHash: false
    labels:
      name: my-java

Build the configMap using the kustomization.yaml file.

kustomize build . | kubectl apply -f -

Create deployment with the newly created configMap along with the postfix. Please note the metadata label must contain the config name and the config postfix that was created initially. say <configname>=<postfix>. Under the VolumeMounts section use the complete name of the configMap along with the postfix.</postfix></configname>

apiVersion: apps/v1
kind: Deployment
metadata:
  name: busybox-deployment
  labels:
    my-java: d6f8m44fmg
    app: busybox
spec:
  replicas: 1
  revisionHistoryLimit: 1
  strategy: 
    type: RollingUpdate
  selector:
    matchLabels:
      app: busybox
  template:
    metadata:
      labels:
        app: busybox
    spec:
      containers:
      - name: busybox
        image: busybox
        imagePullPolicy: IfNotPresent
        command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']
        volumeMounts:
        - mountPath: /test
          name: test-config
      volumes:
      - name: test-config
        configMap:
          name: my-java-d6f8m44fmg

Whenever a new configMap is created through kustomize, Configurator will automatically sync up the related deployments automatically.

Todos

  • Sync Secretes with Deployments
  • Handle Stateful Sets
  • Move Configurator to Operator Framework

License

Apache License 2.0

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.