Skip to content

thatInfrastructureGuy/redeploy-operator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redeploy-operator

Kubernetes Redeploy Operator to redeploy pods in a deployment in the form of rolling updates.

This project is built with help of Operator-SDK.

How it works

Redeploy Operator basically adds a label to PodSpec field in deployments. This triggers a deployment rollout. Type of rollout depends on MaxSurge and MaxUnavailable fields in your deployments.

The label you will see added is the datetime (UTC) field. Eg: redeployed: 2018-08-07-05_28_41

Limitations:

  1. It only works for deployments. ( Statefulsets, replicasets and daemonsets are not covered. )

Installation

  1. Install CRD, rbac and operator.
kubectl apply -f deploy/crd.yaml
kubectl apply -f deploy/rbac.yaml
kubectl apply -f deploy/operator.yaml
  1. Install a demo app:
kubectl create namespace nginx
kubectl run nginx --namespace nginx --image nginx:alpine --replicas=2
  1. Trigger a redeploy:
kubectl apply -f deploy/cr.yaml
  1. See it work:
kubectl -n nginx get pods -w
kubectl -n redeploy-operator logs -l name=redeploy-operator
  1. Check status

    1. Check the custom resource.

    kubectl -n redeploy-operator get redeploies -o yaml

    You should see RedeployNeeded set to false and status fields appended.

    spec:
      DeploymentName: nginx
      DeploymentNamespace: nginx
      RedeployNeeded: false
    status:
      Date: 2018-08-07-05_28_41
      Status: REDEPLOYED
    
    1. Check the deployment

    kubectl -n nginx get deployment nginx -o yaml | grep redeployed

     redeployed: 2018-08-07-05_28_41
    

Building from source:

  1. Install Operator-SDK
  2. operator-sdk generate k8s
  3. operator-sdk build <IMAGE-NAME>
  4. docker push <IMAGE-NAME>

Note: operator.yaml is custom built. It is overwritten upon building the project. Please make necessary changes to make it work.

About

Kubernetes Redeploy Operator to redeploy pods in a deployment in the form of rolling updates.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published