POD
Create an NGINX Pod
1 |
kubectl run nginx --image=nginx |
Generate POD Manifest YAML file (-o yaml). Don’t create it(–dry-run)
1 |
kubectl run nginx --image=nginx --dry-run=client -o yaml |
Deployment
Create a deployment
1 |
kubectl create deployment --image=nginx nginx |
Generate Deployment YAML file (-o yaml). Don’t create it(–dry-run)
1 |
kubectl create deployment --image=nginx nginx --dry-run=client -o yaml |
Save it to a file – (If you need to modify or add some other details)
1 |
kubectl create deployment --image=nginx nginx --dry-run=client -o yaml > nginx-deployment.yaml |
Service
Create a Service named redis-service of type ClusterIP to expose pod redis on port 6379
1 |
kubectl expose pod redis --port=6379 --name redis-service --dry-run=client -o yaml |
Or
1 |
kubectl create service clusterip redis --tcp=6379:6379 --dry-run=client -o yaml |
Create a Service named nginx of type NodePort to expose pod nginx’s port 80 on port 30080 on the nodes:
1 |
kubectl expose pod nginx --port=80 --name nginx-service --type=NodePort --dry-run=client -o yaml |
Or
1 |
kubectl create service nodeport nginx --tcp=80:80 --node-port=30080 --dry-run=client -o yaml |
Latest posts by Zhiming Zhang (see all)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021