Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

about Centos k8s controllers

CRDs are only a mean to specify a configuration, though. The cluster still needs controllers to monitor its state and reconcile the resource to match with the configuration (make consistent with another).Operators are controllers working in association with custom resources to perform tasks that generally… “human operators” have to take care of. Operators are the CRDs associated with controllers which observe and act upon changes in the configuration or changes in the state of the cluster The etcd operator manages etcd clusters deployed to Kubernetes and automates tasks related to operating an etcd cluster.

how this project was created

log on to katacoda k8s course site

install go

install dep

install sdk

Bootstrapping the Go project

  • git config --global
  • git config --global agilesolutions
  • mkdir -p $GOPATH/src/
  • cd $GOPATH/src/
  • operator-sdk new podset-operator
  • tree -I vendor

Add a new API for the custom resource PodSet

  • cd podset-operator
  • operator-sdk add api --kind=PodSet

Add a new controller that watches for PodSet

  • operator-sdk add controller --kind=PodSet

build the Docker image using the Operator SDK

  • operator-sdk build agilesolutions/podset-operator
  • docker login -u agilesolutions
  • docker push agilesolutions/podset-operator

to run this stuff

Setup Service Account

  • kubectl create -f deploy/service_account.yaml

Setup RBAC

  • kubectl create -f deploy/role.yaml
  • kubectl create -f deploy/role_binding.yaml

Setup the CRD

  • kubectl create -f deploy/crds/app_v1alpha1_podset_crd.yaml

Deploy the podset-operator

  • kubectl create -f deploy/operator.yaml

check the CRD

  • kubectl get crd

check the operator controller

  • kubectl get pods

check if there's a CR using the CRD fullname...

  • kubectl get

create our PodSet resource configured with 4 replicas

  • kubectl apply -f examples/replicas4.yaml
  • kubectl get pods -l app=example-podset
  • kubectl delete pods -l app=example-podset
  • kubectl get pods -l app=example-podset
  • kubectl apply -f examples/replicas2.yaml
  • kubectl get pods -l app=example-podset
  • kubectl describe podset/example-podset
  • kubectl delete podset example-podset
  • kubectl get pods -l app=example-podset

more reading on this

writing operators

relevant KUBECTL commands

  • kubectl cluster-info
  • kubectl get nodes
  • kubectl config set-context $(kubectl config current-context) --namespace=default
  • kubectl config view | grep namespace:
  • kubectl get nodes
  • kubectl get deployment componenta --no-headers- kubectl get pods -l app=sa-log --show-labels
  • kubectl get pods --all-namespaces
  • kubectl get pods -n default
  • kubectl get namespaces
  • kubectl get svc -n istio-system -l istio=ingressgateway
  • kubectl get svc -n istio-system -l istio=ingressgateway -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}')
  • kubectl get pods -o wide
  • kubectl get -f pod.yaml -o json
  • kubectl get rc,services
  • kubectl run first-deployment --image=katacoda/docker-http-server --port=80 --replicas=1
  • kubectl expose deployment first-deployment --port=80 --type=NodePort
  • export PORT=$(kubectl get svc first-deployment -o go-template='{{range.spec.ports}}{{if .nodePort}}{{.nodePort}}{{"\n"}}{{end}}{{end}}')
  • kubectl apply -f /opt/kubernetes-dashboard.yaml
  • kubectl get deployments
  • kubectl describe deployment http
  • kubectl run httpexposed --image=katacoda/docker-http-server:latest --replicas=1 --port=80 --hostport=8001
  • kubectl scale --replicas=3 deployment http
  • kubectl create -f deployment.yaml
  • kubectl get deployment
  • Get a Shell to a Running Container
  • Istio traffic management


my first kubernetes operator



No releases published


No packages published