Created
October 2, 2019 16:07
-
-
Save viveksinghggits/22ab2ea7beb07c5d9676810998c76a99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a pod named nginx-pod with image nginx and 3 replicas | |
kubectl run nginx-pod --generator=run-pod/v1 --image=nginx --replicas=3 | |
# create a deployment named nginx-deploy with image nginx and 3 replicas, alternative of below command is kubectl create deployment | |
kubectl run nginx-deploy --image=nginx --replicas=3 | |
# Dont actually create the resources in the cluster, just create the manifest for above commands/resource | |
# below command will create a file named pod.yaml that will be the manifest to create the pod with require specification. | |
kubectl run nginx-pod --generator=run-pod/v1 --image=nginx --replicas=3 --dry-run -oyaml > pod.yaml | |
# once the manifest file is created you can make the required changed and create the resource using | |
kubectl create -f pod.yaml | |
# once you have to pod or deployment created you can expose that pod or deployment using imperative command | |
# what I like about this is, you dont have the headache to get the labels of the pods right, this command will take care of that | |
kubectl expose deployment <deployment-name> --name <nameof-service> --type=<typeof-service> --port=<port> | |
# the above command will create a service that will redirect its traffic to the specified deployment. If you think that | |
# you might need to change something in the service specification you can just create the srvice manifest without | |
# actually creating the service object in the cluster and then make the respective changes in the generated service manifest | |
# and create it on the cluster | |
kubectl expose deployment <deployment-name> --name <nameof-service> --type=<typeof-service> --port=<port> --dry-run -oyaml > service.yaml | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment