Vikas Badoni

Kubernetes interactions using client-go library

Sample application Deployment using Golang.

Creates nginx Deployment, Service, Ingress which is accessible on the localhost.

we create a deployment by defining the deployment struct and then creating it using create method from the deployment interface.

deployment := &appsv1.Deployment{...}
clientSet.AppsV1().Deployments(namespace).Create()

We then wait for the replicas to come online. by first getting the deployment using get method and checking the status field for the readyrelplicas.

checkForReadyReplicas()
currentReadyReplicas := (*deployment).Status.ReadyReplicas

once the replicas are ready we then create the kubenetes service by defining a service struct and using create metod on the services interface.

service := &corev1.Service{...}
clientSet.CoreV1().Services(namespace).Create()

Once the service is ready we create the ingress.

clientSet.NetworkingV1().Ingresses(namespace).Create

Github Code Link

Corev1()

Pods: Github Code Link

Nodes: Github Code Link

Thank You!