Kubernetes Basics

Writing kubernetes manifests is irritating and not practical all times. one of the best ways to generate the manifest is to generate kubernetes components.

Some commands like kubectl expose deployment work only when deployment is present on the kubernetes cluster. Its wise to stick with kubectl create service command to generate service related manifests. Other available generators can be accessed via kubectl create -h command which lists possible examples and help realted to generation of manifests. Also specific help on each particluar generator can be accessed via kubectl create configmap -h. It show examples and help materials regarding generation of configmap realted manifests.

For a pod

kubectl run nginx --image=nginx --dry-run=client -o yaml > nginx-pod.yaml

For a deployment

kubectl create deployment nginx --image=nginx --dry-run=client -o yaml > nginx-deployment.yaml

For a service

kubectl create service clusterip redis --tcp=6379:6379 --dry-run=client -o yaml > redis-service.yaml

For a service

kubectl expose deployment nginx --type=ClusterIP --port=80
kubectl create -h 

For specific help realted to any specific generator

kubectl create configmap -h