apiVersion: v1 kind: Pod metadata: name: my-little-pod spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80 - name: redis image: redis volumeMounts: - name: redis-storage mountPath: /data/redis volumes: - name: redis-storage emptyDir: {}
기존에 존재하는 service 와 deployment가 보이니 해당 pod/service 정보를 삭제하자.
kubectl delete deployment <pod이름>
kubectl delete service <서비스명>
kubectl apply -f simple-pod.yaml
nginx 서버에 접근
kubectl exec --stdin --tty my-little-pod -c nginx --sh
redis-server에 접근
kubectl exec --stdin --tty my-little-pod -c redis --redis-server --version
위에서 생성한 my-little-pod 을 동일하게 3개 복제
이름은 my-replicaset 이며 label 명 역시 동일
apiVersion: apps/v1 kind: ReplicaSet metadata: name: my-replicaset labels: app: my-replicaset spec: replicas: 3 selector: matchLabels: app: my-little-pod template: metadata: labels: app: my-little-pod spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80 - name: redis image: redis volumeMounts: - name: redis-storage mountPath: /data/redis volumes: - name: redis-storage emptyDir: {}
kubectl apply -f simple-replicaset.yaml
kubectl get rs
Get the current ReplicaSets deployed
kubectl describe rs/my-replicaset
Check on the state of the ReplicaSet
kubectl get pods
kubectl get pods my-replicaset-45wkc -o yaml
Get the yaml of a Pod
kubectl exec --stdin --tty my-replicaset-45wkc -c nginx -- sh
특정 replica container에 접속
kubectl exec --stdin --tty my-replicaset-45wkc -c redis -- redis-server --version
kubectl get pod,replicaset,deployment --selector app=my-little-pod
kubectl get pod,replicaset,deployment --selector app=my-replicaset
특정 pod, replicaSet 확인.