카타코더 k8s - Deploy Docker Compose Files with Kompose

1 개요[ | ]

카타코더 Kubernetes - Deploy Docker Compose Files with Kompose
카타코더 Kubernetes - Deploy Docker Compose with Kompose
카타코더 Kubernetes
# 🔗 제목
카타코더 Kubernetes/2 e
🡵 카타코더 k8s - Use Kubernetes To Manage Secrets And Passwords
🡵 카타코더 k8s - Deploy Docker Compose Files with Kompose
🡵 카타코더 k8s - Deploying from source onto Kubernetes
🡵 카타코더 k8s - Backup and Restore with Heptio Ark
🡵 카타코더 k8s - Helm Package Manager
🡵 카타코더 k8s - Installing Weave Scope on Kubernetes
🡵 카타코더 k8s - Getting Started with Kubeless

2 Install[ | ]

master:~$ kubectl get nodes -owide
NAME      STATUS    ROLES     AGE       VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION     CONTAINER-RUNTIME
master    Ready     master    57s       v1.11.3   172.17.0.40   <none>        Ubuntu 16.04.2 LTS   4.4.0-62-generic   docker://1.13.1
node01    Ready     <none>    41s       v1.11.3   172.17.0.42   <none>        Ubuntu 16.04.2 LTS   4.4.0-62-generic   docker://1.13.1
master:~$ curl -L https://github.com/kubernetes/kompose/releases/download/v1.9.0/kompose-linux-amd64 -o /usr/bin/kompose && chmod +x /usr/bin/kompose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   609    0   609    0     0    846      0 --:--:-- --:--:-- --:--:--   847
100 45.6M  100 45.6M    0     0  9668k      0  0:00:04  0:00:04 --:--:-- 11.4M
master:~$ kompose version
1.9.0 (093c756)

3 Up[ | ]

master:~$ ll
total 32
drwx------  5 root root 4096 Mar 23 18:32 ./
drwxr-xr-x 22 root root 4096 Apr 25  2018 ../
-rw-r--r--  1 root root 3291 Oct 13 15:50 .bashrc
drwx------  2 root root 4096 Mar 23 18:28 .cache/
-rw-r--r--  1 root root  355 Mar 23 18:32 docker-compose.yml
-rw-r--r--  1 root root    0 Oct 13 15:49 .hushlogin
drwxr-xr-x  4 root root 4096 Mar 23 18:30 .kube/
-rw-r--r--  1 root root  148 Aug 17  2015 .profile
drwxr-xr-x  2 root root 4096 Oct 13 15:49 .ssh/
master:~$ cat docker-compose.yml
version: "2"
services:
  redis-master:
    image: redis:latest
    ports:
      - "6379"
  redis-slave:
    image: gcr.io/google_samples/gb-redisslave:v1
    ports:
      - "6379"
    environment:
      - GET_HOSTS_FROM=dns
  frontend:
    image: gcr.io/google-samples/gb-frontend:v3
    ports:
      - "80:80"
    environment:
      - GET_HOSTS_FROM=dns
master:~$ kompose up
INFO We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.

INFO Deploying application in "default" namespace
INFO Successfully created Service: frontend
INFO Successfully created Service: redis-master
INFO Successfully created Service: redis-slave
INFO Successfully created Deployment: frontend
INFO Successfully created Deployment: redis-master
INFO Successfully created Deployment: redis-slave

Your application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods,pvc' for details.
master:~$ kubectl get deployment,svc,pods,pvc
NAME                                 DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.extensions/frontend       1         1         1            1           15s
deployment.extensions/redis-master   1         1         1            1           15s
deployment.extensions/redis-slave    1         1         1            1           15s

NAME                   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
service/frontend       ClusterIP   10.101.95.235   <none>        80/TCP     15s
service/kubernetes     ClusterIP   10.96.0.1       <none>        443/TCP    3m
service/redis-master   ClusterIP   10.104.128.14   <none>        6379/TCP   15s
service/redis-slave    ClusterIP   10.103.211.45   <none>        6379/TCP   15s

NAME                                READY     STATUS    RESTARTS   AGE
pod/frontend-7c548dc557-nqtf9       1/1       Running   0          15s
pod/redis-master-6574c44848-ckx79   1/1       Running   0          15s
pod/redis-slave-68b45d6b86-hfd2n    1/1       Running   0          15s

4 Convert[ | ]

master:~$ kompose convert
INFO Kubernetes file "frontend-service.yaml" created
INFO Kubernetes file "redis-master-service.yaml" created
INFO Kubernetes file "redis-slave-service.yaml" created
INFO Kubernetes file "frontend-deployment.yaml" created
INFO Kubernetes file "redis-master-deployment.yaml" created
INFO Kubernetes file "redis-slave-deployment.yaml" created
master:~$ ls
docker-compose.yml        frontend-service.yaml         redis-master-service.yaml    redis-slave-service.yaml
frontend-deployment.yaml  redis-master-deployment.yaml  redis-slave-deployment.yaml
master:~$ kubectl apply -f frontend-service.yaml,redis-master-service.yaml,redis-slave-service.yaml,frontend-deployment.yaml,redis-master-deployment.yaml,redis-slave-deployment.yaml
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
service/frontend configured
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
service/redis-master configured
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
service/redis-slave configured
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
deployment.extensions/frontend configured
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
deployment.extensions/redis-master configured
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
deployment.extensions/redis-slave configured

5 OpenShift[ | ]

master:~$ kompose --provider openshift convert
INFO OpenShift file "frontend-service.yaml" created
INFO OpenShift file "redis-master-service.yaml" created
INFO OpenShift file "redis-slave-service.yaml" created
INFO OpenShift file "frontend-deploymentconfig.yaml" created
INFO OpenShift file "frontend-imagestream.yaml" created
INFO OpenShift file "redis-master-deploymentconfig.yaml" created
INFO OpenShift file "redis-master-imagestream.yaml" created
INFO OpenShift file "redis-slave-deploymentconfig.yaml" created
INFO OpenShift file "redis-slave-imagestream.yaml" created

6 Convert To Json[ | ]

master:~$ kompose convert -j
INFO Kubernetes file "frontend-service.json" created
INFO Kubernetes file "redis-master-service.json" created
INFO Kubernetes file "redis-slave-service.json" created
INFO Kubernetes file "frontend-deployment.json" created
INFO Kubernetes file "redis-master-deployment.json" created
INFO Kubernetes file "redis-slave-deployment.json" created
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}