deploy docker image on kubernetes

#apply patch
[root@k8s-master ~]# cat Dockerfile
FROM openjdk:8-jdk
MAINTAINER gnoti
VOLUME /tmp
ARG JAR_FILE=test.springboot.netty-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
EXPOSE 8088[root@k8s-master ~]#

[root@k8s-master ~]# docker build -t gnotiboot .
Sending build context to Docker daemon    157MB
Step 1/7 : FROM openjdk:8-jdk
 ---> 3e50df58f25e
Step 2/7 : MAINTAINER gnoti
 ---> Running in e3a88d96f015
Removing intermediate container e3a88d96f015
 ---> 5cfc31ae7709
Step 3/7 : VOLUME /tmp
 ---> Running in 7c87f897218c
Removing intermediate container 7c87f897218c
 ---> 002b046cc33b
Step 4/7 : ARG JAR_FILE=test.springboot.netty-0.0.1-SNAPSHOT.jar
 ---> Running in 805698ab8292
Removing intermediate container 805698ab8292
 ---> 539b5c4b2e87
Step 5/7 : COPY ${JAR_FILE} app.jar
 ---> ea2812dc02e7
Step 6/7 : ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
 ---> Running in d6edb5beb32d
Removing intermediate container d6edb5beb32d
 ---> acdd98e98cf1
Step 7/7 : EXPOSE 8080
 ---> Running in be6e2746072b
Removing intermediate container be6e2746072b
 ---> a2c5f76296bf
Successfully built a2c5f76296bf
Successfully tagged gnotiboot:latest
[root@k8s-master ~]#

[root@k8s-master ~]# docker images
REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE
gnotiboot                            latest              a2c5f76296bf        6 seconds ago       530MB
<none>                               <none>              0407d1219c5f        7 minutes ago       530MB
openjdk                              8-jdk               3e50df58f25e        4 days ago          510MB
k8s.gcr.io/kube-proxy                v1.18.0             43940c34f24f        3 weeks ago         117MB
k8s.gcr.io/kube-apiserver            v1.18.0             74060cea7f70        3 weeks ago         173MB
k8s.gcr.io/kube-scheduler            v1.18.0             a31f78c7c8ce        3 weeks ago         95.3MB
k8s.gcr.io/kube-controller-manager   v1.18.0             d3e55153f52f        3 weeks ago         162MB
quay.io/coreos/flannel               v0.12.0-amd64       4e9f801d2217        5 weeks ago         52.8MB
k8s.gcr.io/pause                     3.2                 80d28bedfe5d        2 months ago        683kB
k8s.gcr.io/coredns                   1.6.7               67da37a9a360        2 months ago        43.8MB
k8s.gcr.io/etcd                      3.4.3-0             303ce5db0e90        5 months ago        288MB

[root@k8s-master ~]# docker run -p 9999:8088 gnotiboot

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.6.RELEASE)

2020-04-21 06:53:00.766  INFO 1 --- [           main] example.Application                      : Starting Application v0.0.1-SHOT on ca6b22a340c2 with PID 1 (/app.jar started by root in /)
2020-04-21 06:53:00.773  INFO 1 --- [           main] example.Application                      : No active profile set, falliack to default profiles: default
2020-04-21 06:53:05.082  INFO 1 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port(s): 80
2020-04-21 06:53:05.091  INFO 1 --- [           main] example.Application                      : Started Application in 5.849onds (JVM running for 7.152)
2020-04-21 06:53:05.166  INFO 1 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x67c931bc] REGISTERED
2020-04-21 06:53:05.170  INFO 1 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x67c931bc] BIND: 0.0.0.0.0.0:8088
2020-04-21 06:53:05.175  INFO 1 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x67c931bc, L:/0.0.0.0:] ACTIVE
2020-04-21 06:53:21.533  INFO 1 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x67c931bc, L:/0.0.0.0:] READ: [id: 0xe7796726, L:/172.17.0.2:8088 - R:/192.168.0.190:57823]
2020-04-21 06:53:21.535  INFO 1 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x67c931bc, L:/0.0.0.0:] READ COMPLETE
2020-04-21 06:53:21.536  INFO 1 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x67c931bc, L:/0.0.0.0:] READ: [id: 0xb9c63ecb, L:/172.17.0.2:8088 - R:/192.168.0.190:57824]
2020-04-21 06:53:21.537  INFO 1 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x67c931bc, L:/0.0.0.0:] READ COMPLETE
2020-04-21 06:53:21.540  INFO 1 --- [ntLoopGroup-3-1] io.netty.handler.logging.LoggingHandler  : [id: 0xe7796726, L:/172.17.0088 - R:/192.168.0.190:57823] REGISTERED
2020-04-21 06:53:21.540  INFO 1 --- [ntLoopGroup-3-1] io.netty.handler.logging.LoggingHandler  : [id: 0xe7796726, L:/172.17.0088 - R:/192.168.0.190:57823] ACTIVE
2020-04-21 06:53:21.541  INFO 1 --- [ntLoopGroup-3-2] io.netty.handler.logging.LoggingHandler  : [id: 0xb9c63ecb, L:/172.17.0088 - R:/192.168.0.190:57824] REGISTERED
2020-04-21 06:53:21.541  INFO 1 --- [ntLoopGroup-3-2] io.netty.handler.logging.LoggingHandler  : [id: 0xb9c63ecb, L:/172.17.0088 - R:/192.168.0.190:57824] ACTIVE
2020-04-21 06:53:21.590  INFO 1 --- [ntLoopGroup-3-1] io.netty.handler.logging.LoggingHandler  : [id: 0xe7796726, L:/172.17.0088 - R:/192.168.0.190:57823] READ: 447B
         +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 47 45 54 20 2f 20 48 54 54 50 2f 31 2e 31 0d 0a |GET / HTTP/1.1..|
|00000010| 48 6f 73 74 3a 20 31 39 32 2e 31 36 38 2e 30 2e |Host: 192.168.0.|
|00000020| 31 36 32 3a 39 39 39 39 0d 0a 43 6f 6e 6e 65 63 |162:9999..Connec|
|00000030| 74 69 6f 6e 3a 20 6b 65 65 70 2d 61 6c 69 76 65 |tion: keep-alive|
|00000040| 0d 0a 55 70 67 72 61 64 65 2d 49 6e 73 65 63 75 |..Upgrade-Insecu|
|00000050| 72 65 2d 52 65 71 75 65 73 74 73 3a 20 31 0d 0a |re-Requests: 1..|
|00000060| 55 73 65 72 2d 41 67 65 6e 74 3a 20 4d 6f 7a 69 |User-Agent: Mozi|
|00000070| 6c 6c 61 2f 35 2e 30 20 28 57 69 6e 64 6f 77 73 |lla/5.0 (Windows|
|00000080| 20 4e 54 20 31 30 2e 30 3b 20 57 69 6e 36 34 3b | NT 10.0; Win64;|
|00000090| 20 78 36 34 29 20 41 70 70 6c 65 57 65 62 4b 69 | x64) AppleWebKi|
|000000a0| 74 2f 35 33 37 2e 33 36 20 28 4b 48 54 4d 4c 2c |t/537.36 (KHTML,|
|000000b0| 20 6c 69 6b 65 20 47 65 63 6b 6f 29 20 43 68 72 | like Gecko) Chr|
|000000c0| 6f 6d 65 2f 38 30 2e 30 2e 33 39 38 37 2e 31 36 |ome/80.0.3987.16|
|000000d0| 33 20 53 61 66 61 72 69 2f 35 33 37 2e 33 36 0d |3 Safari/537.36.|
|000000e0| 0a 41 63 63 65 70 74 3a 20 74 65 78 74 2f 68 74 |.Accept: text/ht|
|000000f0| 6d 6c 2c 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 |ml,application/x|
|00000100| 68 74 6d 6c 2b 78 6d 6c 2c 61 70 70 6c 69 63 61 |html+xml,applica|
|00000110| 74 69 6f 6e 2f 78 6d 6c 3b 71 3d 30 2e 39 2c 69 |tion/xml;q=0.9,i|
|00000120| 6d 61 67 65 2f 77 65 62 70 2c 69 6d 61 67 65 2f |mage/webp,image/|
|00000130| 61 70 6e 67 2c 2a 2f 2a 3b 71 3d 30 2e 38 2c 61 |apng,*/*;q=0.8,a|
|00000140| 70 70 6c 69 63 61 74 69 6f 6e 2f 73 69 67 6e 65 |pplication/signe|
|00000150| 64 2d 65 78 63 68 61 6e 67 65 3b 76 3d 62 33 3b |d-exchange;v=b3;|
|00000160| 71 3d 30 2e 39 0d 0a 41 63 63 65 70 74 2d 45 6e |q=0.9..Accept-En|
|00000170| 63 6f 64 69 6e 67 3a 20 67 7a 69 70 2c 20 64 65 |coding: gzip, de|
|00000180| 66 6c 61 74 65 0d 0a 41 63 63 65 70 74 2d 4c 61 |flate..Accept-La|
|00000190| 6e 67 75 61 67 65 3a 20 6b 6f 2d 4b 52 2c 6b 6f |nguage: ko-KR,ko|
|000001a0| 3b 71 3d 30 2e 39 2c 65 6e 2d 55 53 3b 71 3d 30 |;q=0.9,en-US;q=0|
|000001b0| 2e 38 2c 65 6e 3b 71 3d 30 2e 37 0d 0a 0d 0a    |.8,en;q=0.7.... |
+--------+-------------------------------------------------+----------------+

[root@k8s-master ~]# docker tag gnotiboot docker.io/gnoti/kube-test:0.1
[root@k8s-master ~]# docker push docker.io/gnoti/kube-test:0.1
The push refers to repository [docker.io/gnoti/kube-test]
f85ce2305a62: Layer already exists
c46c0b39fa89: Layer already exists
5977227d48fa: Layer already exists
27974e3533d3: Layer already exists
d35c5bda4793: Layer already exists
a3c1026c6bcc: Layer already exists
f1d420c2af1a: Layer already exists
461719022993: Layer already exists
0.1: digest: sha256:14cf6a2add3a88891d4118b2a38b8c1b26d333132600c5d2cb4e5f60978c8296 size: 2006
[root@k8s-master ~]#

[root@k8s-master ~]# cat gnotiboot.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gnotiboot-docker-deployment
  labels:
    app: gnotiboot-docker
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gnotiboot-docker
  template:
    metadata:
      labels:
        app: gnotiboot-docker
    spec:
      containers:
      - name: gnotiboot-docker
        image: gnoti/kube-test:0.1
        ports:
        - containerPort: 8088
        imagePullPolicy: Always
        resources:
          requests:
            memory: "256Mi"
            cpu: "200m"
          limits:
            memory: "1Gi"
            cpu: "500m"
[root@k8s-master ~]#


[root@k8s-master ~]# kubectl apply --record -f ./gnotiboot.yaml
deployment.apps/gnotiboot-docker-deployment created
[root@k8s-master ~]#
[root@k8s-master ~]#
[root@k8s-master ~]# kubectl get pods
NAME                                           READY   STATUS              RESTARTS   AGE
gnotiboot-docker-deployment-5b896fb5b6-pbrqt   0/1     ContainerCreating   0          19s
gtomcat                                        1/1     Running             0          14d
nginx-f89759699-5vtq5                          1/1     Running             0          16d
php-apache-5c4f475bf5-6ch8v                    1/1     Running             0          22h
[root@k8s-master ~]#
[root@k8s-master ~]# kubectl get pods
NAME                                           READY   STATUS    RESTARTS   AGE
gnotiboot-docker-deployment-5b896fb5b6-pbrqt   1/1     Running   0          2m10s
gtomcat                                        1/1     Running   0          14d
nginx-f89759699-5vtq5                          1/1     Running   0          16d
php-apache-5c4f475bf5-6ch8v                    1/1     Running   0          22h
[root@k8s-master ~]# kubectl get pods -o wide
NAME                                           READY   STATUS    RESTARTS   AGE     IP            NODE        NOMINATED NODE ADINESS GATES
gnotiboot-docker-deployment-5b896fb5b6-pbrqt   1/1     Running   0          2m40s   10.244.1.33   k8s-node1   <none>         one>
gtomcat                                        1/1     Running   0          14d     10.244.1.13   k8s-node1   <none>         one>
nginx-f89759699-5vtq5                          1/1     Running   0          16d     10.244.1.4    k8s-node1   <none>         one>
php-apache-5c4f475bf5-6ch8v                    1/1     Running   0          22h     10.244.1.26   k8s-node1   <none>         one>


[root@k8s-master ~]# kubectl get po
NAME                                           READY   STATUS    RESTARTS   AGE
gnotiboot-docker-deployment-7db84d5dbb-s5jxf   1/1     Running   0          10s
gtomcat                                        1/1     Running   0          14d
nginx-f89759699-5vtq5                          1/1     Running   0          16d
php-apache-5c4f475bf5-6ch8v                    1/1     Running   0          22h
[root@k8s-master ~]#
[root@k8s-master ~]#
[root@k8s-master ~]#
[root@k8s-master ~]#  kubectl get hpa
NAME         REFERENCE               TARGETS   MINPODS   MAXPODS   REPLICAS   AGE
php-apache   Deployment/php-apache   0%/50%    1         10        1          22h
[root@k8s-master ~]#  kubectl  get pods  --all-namespaces
NAMESPACE     NAME                                           READY   STATUS    RESTARTS   AGE
default       gnotiboot-docker-deployment-7db84d5dbb-s5jxf   1/1     Running   0          53s
default       gtomcat                                        1/1     Running   0          14d
default       nginx-f89759699-5vtq5                          1/1     Running   0          16d
default       php-apache-5c4f475bf5-6ch8v                    1/1     Running   0          22h
kube-system   coredns-66bff467f8-glbj5                       1/1     Running   0          16d
kube-system   coredns-66bff467f8-s9zp2                       1/1     Running   0          16d
kube-system   etcd-k8s-master                                1/1     Running   0          16d
kube-system   kube-apiserver-k8s-master                      1/1     Running   0          16d
kube-system   kube-controller-manager-k8s-master             1/1     Running   0          16d
kube-system   kube-proxy-s7kws                               1/1     Running   0          16d
kube-system   kube-proxy-wd7dj                               1/1     Running   0          16d
kube-system   kube-scheduler-k8s-master                      1/1     Running   0          16d
kube-system   metricbeat-759cc94485-4p2zs                    1/1     Running   0          17h
kube-system   metricbeat-8wdvl                               1/1     Running   0          17h
kube-system   metrics-server-67c75d59f8-7dsrv                1/1     Running   0          20h
[root@k8s-master ~]#
[root@k8s-master ~]# kubectl get pods gnotiboot-docker-deployment-7db84d5dbb-s5jxf
NAME                                           READY   STATUS    RESTARTS   AGE
gnotiboot-docker-deployment-7db84d5dbb-s5jxf   1/1     Running   0          2m15s
[root@k8s-master ~]# kubectl logs gnotiboot-docker-deployment-7db84d5dbb-s5jxf

[root@k8s-master ~]# kubectl logs gnotiboot-docker-deployment-7db84d5dbb-s5jxf

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.6.RELEASE)

2020-04-21 07:02:02.079  INFO 1 --- [           main] example.Application                      : Starting Application v0.0.1-SHOT on gnotiboot-docker-deployment-7db84d5dbb-s5jxf with PID 1 (/app.jar started by root in /)
2020-04-21 07:02:02.090  INFO 1 --- [           main] example.Application                      : No active profile set, falliack to default profiles: default
2020-04-21 07:02:23.875  INFO 1 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port(s): 80
2020-04-21 07:02:23.967  INFO 1 --- [           main] example.Application                      : Started Application in 25.90conds (JVM running for 30.41)
2020-04-21 07:02:24.189  INFO 1 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x0bc1fd86] REGISTERED
2020-04-21 07:02:24.191  INFO 1 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x0bc1fd86] BIND: 0.0.0.0.0.0:8088
2020-04-21 07:02:24.270  INFO 1 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x0bc1fd86, L:/0.0.0.0:] ACTIVE
[root@k8s-master ~]# curl 10.244.1.34:8088
GET / HTTP/1.1
User-Agent: curl/7.29.0
Host: 10.244.1.34:8088
Accept: */*

####
kubectl run gnotiboot --replicas=2 --labels="run=LoadBalancer" --image=gnoti/kube-test:0.1  --port=8088


댓글

이 블로그의 인기 게시물

[!] CDN: trunk URL couldn't be downloaded: https://cdn.cocoapods.org/CocoaPods-version.yml Response: URL using bad/illegal format or missing URL

starcraft map

Data Analysis with Superset - boardless chart