[Pod]
- Create an NGINX Pod
kubectl run nginx --image=nginx
- Generate POD Manifest YAML file (-o yaml). Don't create it(--dry-run)
kubectl run nginx --image=nginx --dry-run=client -o yaml
[Deployment]
- create a deployment
kubectl create deploymnet --iage=nginx nginx
- Generate Deployment YAML file (-o yaml). Don't create it (--dry-run)
kubectl create deployment --image=nginx nginx --dry-run -o yaml
- Generate Deployment with 4 Replicas
kubectl create deployment nginx --image=nginx --replicas=4
- Create a deployment with kubectl scale
kubectl scale deploymnet nginx --replicas=4
- Another way to do this to save the YAML definition to a file.
kubectl create deployment nginx --image=nginx --dry-run=client -o yaml > nginx-deployment.yaml
[Service]
- Create a Service named redis-service of the ClusterIP to expose pod redis on port 6379
kubectl expose pod redis --port=6379 --name redis-service --dry-run=client -o yaml
자동으로 selectors로서 Pod의 label 사용된다.
or
kubectl create service clusterip redis --tcp=6379:6379 --dry-run=client -o yaml
이것은 selector 로서 pod의 label이 사용되는것 대시 app=redis가 selector로서 사용된다. 옵션으로 selector를 사용할수 없다.
- 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
위 명령으로는 nodeport를 지정할 수 없어 yaml 파일에서 수정해줘야 한다.
or
kubectl create service nodeport nginx --tcp=80:80 --node-port=30080 --dry-run=client -o yaml
'CKA &. CKAD > Core Concepts' 카테고리의 다른 글
kubectl apply command (0) | 2021.03.25 |
---|---|
Practice Test - Imperative Command (0) | 2021.03.25 |
Imperative vs Declarative (0) | 2021.03.24 |
Practice Test - Service (0) | 2021.03.24 |
Service (0) | 2021.03.24 |