카타코더 k8s - Deploy Containers Using YAML

1 개요[ | ]

카타코더 Kubernetes - Deploy Containers Using YAML
카타코더 Kubernetes
# 🔗 제목
카타코더 Kubernetes/1 e
🡵 카타코더 k8s - Launch A Single Node Cluster
🡵 카타코더 k8s - Launch a multi-node cluster using Kubeadm
🡵 카타코더 k8s - Deploy Containers Using Kubectl
🡵 카타코더 k8s - Deploy Containers Using YAML
🡵 카타코더 k8s - Deploy Guestbook Web App Example
🡵 카타코더 k8s - Networking Introduction
🡵 카타코더 k8s - Create Ingress Routing
🡵 카타코더 k8s - Liveness and Readiness Healthchecks
🡵 카타코더 k8s - Getting Started With CRI-O and Kubeadm
🡵 카타코더 k8s - Running Stateful Services on Kubernetes

2 Create Deployment[ | ]

$ cat deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: webapp1
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: webapp1
    spec:
      containers:
      - name: webapp1
        image: katacoda/docker-http-server:latest
        ports:
        - containerPort: 80
$ kubectl create -f deployment.yaml
deployment.extensions/webapp1 created
$ kubectl get deployment
NAME      READY   UP-TO-DATE   AVAILABLE   AGE
webapp1   1/1     1            1           27s
$ kubectl describe deployment webapp1
Name:                   webapp1
Namespace:              default
CreationTimestamp:      Sat, 23 Mar 2019 13:47:03 +0000
Labels:                 app=webapp1
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=webapp1
Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  1 max unavailable, 1 max surge
Pod Template:
  Labels:  app=webapp1
  Containers:
   webapp1:
    Image:        katacoda/docker-http-server:latest
    Port:         80/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
OldReplicaSets:  <none>
NewReplicaSet:   webapp1-56c5865f49 (1/1 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  35s   deployment-controller  Scaled up replica set webapp1-56c5865f49 to 1

3 Create Service[ | ]

$ cat service.yaml
apiVersion: v1
kind: Service
metadata:
  name: webapp1-svc
  labels:
    app: webapp1
spec:
  type: NodePort
  ports:
  - port: 80
    nodePort: 30080
  selector:
    app: webapp1
$ kubectl create -f service.yaml
service/webapp1-svc created
$ kubectl get svc
NAME          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
kubernetes    ClusterIP   10.96.0.1       <none>        443/TCP        3m23s
webapp1-svc   NodePort    10.107.222.86   <none>        80:30080/TCP   7s
$ kubectl describe svc webapp1-svc
Name:                     webapp1-svc
Namespace:                default
Labels:                   app=webapp1
Annotations:              <none>
Selector:                 app=webapp1
Type:                     NodePort
IP:                       10.107.222.86
Port:                     <unset>  80/TCP
TargetPort:               80/TCP
NodePort:                 <unset>  30080/TCP
Endpoints:                172.18.0.4:80
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>
$ curl host01:30080
<h1>This request was processed by host: webapp1-56c5865f49-bdckc</h1>

4 Scale Deployment[ | ]

$ cat deployment.yaml | grep replicas
  replicas: 1
$ sed 's/replicas: 1/replicas: 4/g' -i deployment.yaml
$ cat deployment.yaml | grep replicas
  replicas: 4
$ kubectl apply -f deployment.yaml
deployment.extensions/webapp1 configured
$ kubectl get deployment
NAME      READY   UP-TO-DATE   AVAILABLE   AGE
webapp1   4/4     4            4           4m40s
$ kubectl get pods
NAME                       READY   STATUS    RESTARTS   AGE
webapp1-56c5865f49-977kk   1/1     Running   0          16s
webapp1-56c5865f49-bdckc   1/1     Running   0          4m48s
webapp1-56c5865f49-fwtrx   1/1     Running   0          16s
webapp1-56c5865f49-gsx8z   1/1     Running   0          16s
$ curl host01:30080
<h1>This request was processed by host: webapp1-56c5865f49-bdckc</h1>
$ curl host01:30080
<h1>This request was processed by host: webapp1-56c5865f49-bdckc</h1>
$ curl host01:30080
<h1>This request was processed by host: webapp1-56c5865f49-bdckc</h1>
$ curl host01:30080
<h1>This request was processed by host: webapp1-56c5865f49-977kk</h1>
$ curl host01:30080
<h1>This request was processed by host: webapp1-56c5865f49-fwtrx</h1>
$ curl host01:30080
<h1>This request was processed by host: webapp1-56c5865f49-gsx8z</h1>
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}