728x90
반응형
# jenkins 을 다운로드 하여 실행
docker pull jenkins/jenkins:lts-jdk11
kubectl create deploy jenkins --image=jenkins/jenkins:lts-jdk11 --port 8080
or
kubectl create deploy jenkins --image=jenkins/jenkins:lts-jdk11
kubectl get pod
kubectl get pod -w
ec2-user:~/environment $ kubectl create deploy jenkins --image=jenkins/jenkins:lts-jdk11
deployment.apps/jenkins created
ec2-user:~/environment $ kubectl get pod -w
NAME READY STATUS RESTARTS AGE
jenkins-9df675f7-dp2db 1/1 Running 0 61s
# expose하여 외부에서 서비스 접근 허용하도록 설정
kubectl expose deploy jenkins --type=LoadBalancer --name jenkins-svc
or
ec2-user:~/environment $ kubectl expose deploy jenkins --type=LoadBalancer --name jenkins-svc --port 8080
service/jenkins-svc exposed
kubectl get svc -w
# jenkins 초기 해시 코드값을 찾기위해 쿠버네티스로 접근하여 확인
kubectl get pod
kubectl exec [podNAME] -- cat [jenkins 초기화면 패스워드 경로]
kubectl exec jenkins-7ffb988b7-jwnjw cat /var/jenkins_home/secrets/initialAdminPassword
ec2-user:~/environment $ kubectl get pod
NAME READY STATUS RESTARTS AGE
jenkins-9df675f7-dp2db 1/1 Running 0 4m33s
ec2-user:~/environment $ kubectl exec jenkins-9df675f7-dp2db cat /var/jenkins_home/secrets/initialAdminPassword
5fd49c705e694c9aadfc7f028303b13f
ec2-user:~/environment $
# 다른 방법으로 jenkins 해쉬값 확인
kubectl logs [NAME]
kubectl logs jenkins-7ffb988b7-jwnjw
ec2-user:~/environment $ kubectl logs jenkins-9df675f7-dp2db
Running from: /usr/share/jenkins/jenkins.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
2021-10-05 11:58:20.313+0000 [id=1] INFO org.eclipse.jetty.util.log.Log#initialized: Logging initialized @723ms to org.eclipse.jetty.util.log.JavaUtilLog
2021-10-05 11:58:20.446+0000 [id=1] INFO winstone.Logger#logInternal: Beginning extraction from war file
2021-10-05 11:58:21.480+0000 [id=1] WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2021-10-05 11:58:21.550+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: jetty-9.4.42.v20210604; built: 2021-06-04T17:33:38.939Z; git: 5cd5e6d2375eeab146813b0de9f19eda6ab6e6cb; jvm 11.0.12+7
2021-10-05 11:58:21.933+0000 [id=1] INFO o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2021-10-05 11:58:21.975+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0
2021-10-05 11:58:21.975+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults
2021-10-05 11:58:21.976+0000 [id=1] INFO o.e.j.server.session.HouseKeeper#startScavenging: node0 Scavenging every 660000ms
2021-10-05 11:58:22.629+0000 [id=1] INFO hudson.WebAppMain#contextInitialized: Jenkins home directory: /var/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
2021-10-05 11:58:22.871+0000 [id=1] INFO o.e.j.s.handler.ContextHandler#doStart: Started w.@3a01773b{Jenkins v2.303.1,/,file:///var/jenkins_home/war/,AVAILABLE}{/var/jenkins_home/war}
2021-10-05 11:58:22.919+0000 [id=1] INFO o.e.j.server.AbstractConnector#doStart: Started ServerConnector@3f0846c6{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2021-10-05 11:58:22.922+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: Started @3333ms
2021-10-05 11:58:22.935+0000 [id=23] INFO winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
2021-10-05 11:58:23.248+0000 [id=29] INFO jenkins.InitReactorRunner$1#onAttained: Started initialization
2021-10-05 11:58:23.285+0000 [id=28] INFO jenkins.InitReactorRunner$1#onAttained: Listed all plugins
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$2 (file:/var/jenkins_home/war/WEB-INF/lib/guice-4.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2021-10-05 11:58:24.807+0000 [id=29] INFO jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
2021-10-05 11:58:24.814+0000 [id=28] INFO jenkins.InitReactorRunner$1#onAttained: Started all plugins
2021-10-05 11:58:24.847+0000 [id=28] INFO jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
2021-10-05 11:58:25.814+0000 [id=29] INFO jenkins.InitReactorRunner$1#onAttained: System config loaded
2021-10-05 11:58:25.815+0000 [id=29] INFO jenkins.InitReactorRunner$1#onAttained: System config adapted
2021-10-05 11:58:25.815+0000 [id=29] INFO jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
2021-10-05 11:58:25.816+0000 [id=29] INFO jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
2021-10-05 11:58:25.874+0000 [id=42] INFO hudson.model.AsyncPeriodicWork#lambda$doRun$0: Started Download metadata
2021-10-05 11:58:25.906+0000 [id=42] INFO hudson.util.Retrier#start: Attempt #1 to do the action check updates server
2021-10-05 11:58:26.607+0000 [id=29] INFO jenkins.install.SetupWizard#init:
*************************************************************
*************************************************************
*************************************************************
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
5fd49c705e694c9aadfc7f028303b13f
This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
*************************************************************
*************************************************************
*************************************************************
2021-10-05 11:58:47.846+0000 [id=28] INFO jenkins.InitReactorRunner$1#onAttained: Completed initialization
2021-10-05 11:58:47.868+0000 [id=22] INFO hudson.WebAppMain$3#run: Jenkins is fully up and running
2021-10-05 11:58:48.462+0000 [id=42] INFO h.m.DownloadService$Downloadable#load: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
2021-10-05 11:58:48.463+0000 [id=42] INFO hudson.util.Retrier#start: Performed the action check updates server successfully at the attempt #1
2021-10-05 11:58:48.465+0000 [id=42] INFO hudson.model.AsyncPeriodicWork#lambda$doRun$0: Finished Download metadata. 22,586 ms
2021-10-05 12:01:04.614+0000 [id=64] INFO hudson.model.AsyncPeriodicWork#lambda$doRun$0: Started Periodic background build discarder
2021-10-05 12:01:04.615+0000 [id=64] INFO hudson.model.AsyncPeriodicWork#lambda$doRun$0: Finished Periodic background build discarder. 0 ms
ec2-user:~/environment $
# jenkins 웹 페이지로 접근 > EXTERNAL-IP:8080 으로 접근
ec2-user:~/environment $ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
http-go-svc LoadBalancer 10.100.31.13 acccca471d55b411c856821970f7e81a-1523375836.ap-northeast-2.elb.amazonaws.com 8080:32482/TCP 140m
jenkins-svc LoadBalancer 10.100.60.15 a659db785a08d45408c98ba8506fa56b-2028454087.ap-northeast-2.elb.amazonaws.com 8080:30027/TCP 4m31s
kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 42h
ec2-user:~/environment $
- 서비스 정상 접근 확인
- 토큰값 입력하여 jenkins 관리자 페이지로 접근하기
- 자동으로 플러그인을 설치하고 있는 모습
- jenkins 로그인 모습
# jenkins pod 스케일 아웃 후 서비스 확인 > 3개의 pod로 스케일 아웃된것을 확인
ec2-user:~/environment $ kubectl scale deploy jenkins --replicas=3
deployment.apps/jenkins scaled
ec2-user:~/environment $ kubectl get pod -w
NAME READY STATUS RESTARTS AGE
jenkins-9df675f7-4q89p 1/1 Running 0 15s
jenkins-9df675f7-dp2db 1/1 Running 0 14m
jenkins-9df675f7-k2rfq 0/1 ContainerCreating 0 15s
jenkins-9df675f7-k2rfq 1/1 Running 0 16s
ec2-user:~/environment $ kubectl get pod
NAME READY STATUS RESTARTS AGE
jenkins-9df675f7-4q89p 1/1 Running 0 93s
jenkins-9df675f7-dp2db 1/1 Running 0 15m
jenkins-9df675f7-k2rfq 1/1 Running 0 93s
ec2-user:~/environment $
# jenkins이 어떤 노드에서 실행되는지 노드 정보 확인 > LB 되어 worker 노드 2개에서 번갈아 가면서 실행될 것이다.
ec2-user:~/environment $ kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
jenkins-9df675f7-4q89p 1/1 Running 0 2m22s 192.168.0.98 ip-192-168-19-0.ap-northeast-2.compute.internal <none> <none>
jenkins-9df675f7-dp2db 1/1 Running 0 16m 192.168.6.116 ip-192-168-19-0.ap-northeast-2.compute.internal <none> <none>
jenkins-9df675f7-k2rfq 1/1 Running 0 2m22s 192.168.51.136 ip-192-168-39-178.ap-northeast-2.compute.internal <none> <none>
ec2-user:~/environment $
# jenkins pod 스케일 인 > replicas=0 으로 서비스를 없앤다.
ec2-user:~/environment $ kubectl scale deploy jenkins --replicas=0
deployment.apps/jenkins scaled
ec2-user:~/environment $ kubectl get pod
No resources found in default namespace.
ec2-user:~/environment $
끝.
728x90
반응형
'⭐ Kubernetes & EKS > EKS' 카테고리의 다른 글
EKS Jenkins 디스크럽터 작성 (0) | 2021.10.05 |
---|---|
EKS Pod 디스크립터 작성 (0) | 2021.10.05 |
EKS Pod 와 스케일링(스케일 인, 스케일 아웃) (0) | 2021.10.05 |
Docker 컨테이너를 EKS 에서 실행하기 (0) | 2021.10.05 |
EKS 버전 업데이트 (0) | 2021.10.05 |