K8S Imperative / Declarative Commands
- imperative: 반드시 해야 하는
- declarative: 서술문[평서문]의
1. Imperative Commands
가. Create Objects
> kubectl run --image=nginx nginx
> kubectl create deployment --image=nginx nginx
> kubectl expose deployment nginx --port 80
나. Update Objects
> kubectl edit deployment nginx
> kubectl scale deployment nginx --replicas=5
> kubectl set image deployment nginx nginx=nginx:1.18
다. yaml파일 이용
> kubectl create -f nginx.yaml
> kubectl replace -f nginx.yaml
> kubectl delete -f nginx.yaml
2. Declarative Commands
> kubectl apply -f nginx.yaml
---------------------------------------------------------------------------------------------
Imperative Object Configuarion Files
1. Create Objects
> kubectl create -f nginx.yaml
2. Update Objects
> kubectl edit deployment nginx
> kubectl replace -f nginx.yaml
> kubectl replace --force -f nginx.yaml
> kubectl create -f nginx.yaml
> kubectl replace -f nginx.yaml
*** nginx.yaml
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end-service
spec:
containers:
- name: nginx-container
image: nginx:1.18
---------------------------------------------------------------------------------------------
Declarative Object Configuarion Files
1. Create Objects
> kubectl apply -f nginx.yaml
> kubectl apply -f /path/to/config-files
2. Update Objects
> kubectl apply -f nginx.yaml
*** nginx.yaml
---------------------------------------------------------------------------------------------
Exam Tips
1. Create Objects
> kubectl run --image=nginx nginx
> kubectl create deployment --imag=nginx nginx
> kubectl expose deployment nginx --port 80
2. Update Objects
> kubectl edit deployment nginx
> kubectl scale deployment nginx --replicas=5
> kubectl set image deployment nginx nginx=nginx:1.18
---------------------------------------------------------------------------------------------
kubectl run nginx-pod --image=nginx:alpine
kubectl run --help
kubectl run redis --image=redis:alpine --labels="tier=db"
kubectl create service --help
kubectl create service clusterip --help
kubectl get pods
kubectl expose pod redis --port 6379 --name redis-service
kubectl get svc redis-service
kubectl describe svc redis-service
kubectl create deployment webapp --image=kodekcloud/webapp-color --replicas=3
kubectl get deploy
kubectl run custom-nginx --image=nginx --port=8080
kubectl create namespace dev-ns
kubectl create deployment redis-deploy --image=redis --replicas=2 -n dev-ns
kubectl get deployment -n dev-ns
kubectl run httpd --image=httpd:alpine --port=80 --expose=true
kubectl run --help
kubectl get pod
kubectl get sv
kubectl describe svc httpd
'개발 및 관리 > 클라우드' 카테고리의 다른 글
(K8S 기본 오브젝트) Pod, Volume, Service, Namespace, Label, Controller (0) | 2023.09.07 |
---|---|
Container와 Devops, MSA (0) | 2023.09.06 |
K8S, Services Command, Services-LoandBalancer (0) | 2023.09.01 |
K8S, Services Command (0) | 2023.08.29 |
K8S, Deployment Command (0) | 2023.08.28 |