티스토리 뷰

공부

[k8s] Deployment & replicas

승가비 2022. 4. 26. 16:13
728x90
kubia.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kubia
spec:
  replicas: 3
  selector:
    matchLabels:
      app: kubia
  template:
    metadata:
      labels:
        app: kubia
    spec:
      containers:
        - name: kubia
          image: seunggab/kubia:latest
          ports:
          - containerPort: 8080

shell

kubectl apply -f kubia.yaml
kubectl expose deployment kubia --type=LoadBalancer --port 8080 --name kubia-http

minikube tunnel &

curl 127.0.0.1:8080

if you change replicas

  1. change kubia.yaml (3 -> 5)
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kubia
spec:
  replicas: 5
  selector:
    matchLabels:
      app: kubia
  template:
    metadata:
      labels:
        app: kubia
    spec:
      containers:
        - name: kubia
          image: seunggab/kubia:latest
          ports:
          - containerPort: 8080
  1. re-apply
kubectl apply -f kubia.yaml

# as-is
NAME                     READY   STATUS    RESTARTS   AGE
kubia-5f896dc5d5-qp7wl   1/1     Running   0          20s
kubia-5f896dc5d5-rqqm5   1/1     Running   0          20s
kubia-5f896dc5d5-vqgj9   1/1     Running   0          20s

# to-be
NAME                     READY   STATUS              RESTARTS   AGE
kubia-5f896dc5d5-fsd49   0/1     ContainerCreating   0          6s
kubia-5f896dc5d5-qp7wl   1/1     Running             0          3m35s
kubia-5f896dc5d5-rqqm5   1/1     Running             0          3m35s
kubia-5f896dc5d5-vqgj9   1/1     Running             0          3m35s
kubia-5f896dc5d5-x84fr   1/1     Running             0          6s

https://stackoverflow.com/questions/64306744/error-when-trying-to-expose-a-docker-container-in-minikube

 

Error when trying to expose a docker container in minikube

I am using minikube to learn about docker, but I have come across a problem. I am following along with the examples in Kubernetes in Action, and I am trying to get a pod that I have pulled from my ...

stackoverflow.com

 

728x90
댓글
댓글쓰기 폼