-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-yaml-file
23 lines (17 loc) · 1.24 KB
/
generate-yaml-file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Create an NGINX Pod
kubectl run nginx --image=nginx
kubectl run nginx --image=nginx --dry-run=client -o yaml > gen-nginx-pod.yaml
# Create a deployment
kubectl create deployment --image=nginx nginx
kubectl create deployment --image=nginx nginx --dry-run=client -o yaml > gen-nginx-deployment.yaml
# Create a Service named redis-service of type ClusterIP to expose pod redis on port 6379
kubectl expose pod redis --port=6379 --name redis-service --dry-run=client -o yaml > gen-service-clusterip.yaml
kubectl create service clusterip redis --tcp=6379:6379 --dry-run=client -o yaml > gen-service-clusterip.yaml
(This will not use the pods labels as selectors, instead it will assume selectors as app=redis.
You cannot pass in selectors as an option. So it does not work very well if your pod has a different label set.
So generate the file and modify the selectors before creating the service)
# Create a Service named nginx of type NodePort to expose pod nginx's port 80 on port 30080 on the nodes:
kubectl expose pod nginx --port=80 --name nginx-service --type=NodePort --dry-run=client -o yaml > gen-service-nodeport.yaml
kubectl create service nodeport nginx --tcp=80:80 --node-port=30080 --dry-run=client -o yaml > gen-service-nodeport.yaml