본문 바로가기

⭐ Kubernetes & EKS/EKS

EKS Jenkins 디스크럽터 작성

728x90
반응형

# jenkins 실행을 위한 yaml 파일을 생성

vim jenkins-manual-pod.yaml

# 파일 내용 입력

apiVersion: v1
kind: Pod
metadata:
  name: jenkins-manual
spec:
  containers:
  - name: jenkins
    image: jenkins/jenkins:lts
    ports:
    - containerPort: 8080

# jenkins pod 생성 및 실행

kubectl create -f jenkins-manual-pod.yaml

kubectl get pod

kubectl exec jenkins-manual -- curl 127.0.0.1:8080

kubectl exec jenkins-manual -- curl 127.0.0.1:8080 -s
ec2-user:~/environment $ kubectl exec jenkins-manual -- curl 127.0.0.1:8080
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   541  100   541    0     0    765      0 --:--:-- --:--:-- --:--:--   767
<html><head><meta http-equiv='refresh' content='1;url=/login?from=%2F'/><script>window.location.replace('/login?from=%2F');</script></head><body style='background-color:white; color:white;'>


Authentication required
<!--
-->

</body></html>                                                                                                                                                                                                                                                                                                            ec2-user:~/environment $

# jenkins port를 포트포워딩

kubectl port-forward jenkins-manual 8888:8080

127.0.0.:8888 > AWS의 로컬호스트가 어떻게 되는지는 도통 잘 모르겠다... ㅠ _ ㅠ

# jenkins 초기 패스워드 입력

kubectl logs jenkins-manual
ec2-user:~/environment $ kubectl logs jenkins-manual
Running from: /usr/share/jenkins/jenkins.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
2021-10-05 13:40:18.096+0000 [id=1]     INFO    org.eclipse.jetty.util.log.Log#initialized: Logging initialized @766ms to org.eclipse.jetty.util.log.JavaUtilLog
2021-10-05 13:40:18.204+0000 [id=1]     INFO    winstone.Logger#logInternal: Beginning extraction from war file
2021-10-05 13:40:19.194+0000 [id=1]     WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2021-10-05 13:40:19.264+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 13:40:19.672+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 13:40:19.735+0000 [id=1]     INFO    o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0
2021-10-05 13:40:19.735+0000 [id=1]     INFO    o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults
2021-10-05 13:40:19.736+0000 [id=1]     INFO    o.e.j.server.session.HouseKeeper#startScavenging: node0 Scavenging every 660000ms
2021-10-05 13:40:20.377+0000 [id=1]     INFO    hudson.WebAppMain#contextInitialized: Jenkins home directory: /var/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
2021-10-05 13:40:20.597+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 13:40:20.668+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 13:40:20.669+0000 [id=1]     INFO    org.eclipse.jetty.server.Server#doStart: Started @3340ms
2021-10-05 13:40:20.675+0000 [id=23]    INFO    winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
2021-10-05 13:40:20.948+0000 [id=29]    INFO    jenkins.InitReactorRunner$1#onAttained: Started initialization
2021-10-05 13:40:20.997+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 13:40:22.545+0000 [id=29]    INFO    jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
2021-10-05 13:40:22.551+0000 [id=28]    INFO    jenkins.InitReactorRunner$1#onAttained: Started all plugins
2021-10-05 13:40:22.577+0000 [id=29]    INFO    jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
2021-10-05 13:40:23.811+0000 [id=28]    INFO    jenkins.InitReactorRunner$1#onAttained: System config loaded
2021-10-05 13:40:23.811+0000 [id=28]    INFO    jenkins.InitReactorRunner$1#onAttained: System config adapted
2021-10-05 13:40:23.812+0000 [id=28]    INFO    jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
2021-10-05 13:40:23.812+0000 [id=28]    INFO    jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
2021-10-05 13:40:24.256+0000 [id=42]    INFO    hudson.model.AsyncPeriodicWork#lambda$doRun$0: Started Download metadata
2021-10-05 13:40:24.272+0000 [id=42]    INFO    hudson.util.Retrier#start: Attempt #1 to do the action check updates server
2021-10-05 13:40:24.506+0000 [id=28]    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:

565519d8d5c443339230e50370b243a9

This may also be found at: /var/jenkins_home/secrets/initialAdminPassword

*************************************************************
*************************************************************
*************************************************************

2021-10-05 13:40:45.799+0000 [id=29]    INFO    jenkins.InitReactorRunner$1#onAttained: Completed initialization
2021-10-05 13:40:45.823+0000 [id=22]    INFO    hudson.WebAppMain$3#run: Jenkins is fully up and running
2021-10-05 13:40:46.436+0000 [id=42]    INFO    h.m.DownloadService$Downloadable#load: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
2021-10-05 13:40:46.437+0000 [id=42]    INFO    hudson.util.Retrier#start: Performed the action check updates server successfully at the attempt #1
2021-10-05 13:40:46.447+0000 [id=42]    INFO    hudson.model.AsyncPeriodicWork#lambda$doRun$0: Finished Download metadata. 22,183 ms
ec2-user:~/environment $

- 패스워드 복사 후 웹페이지에 붙여넣어 인증 확인

# jenkins-manual pod 를 yaml 파일로 출력하기

kubectl get pod jenkins-manual -o yaml

kubectl describe pod jenkins-manual

* 간혹가다 쿠버네티스 서비스를 실행시켰는데 상태가 pending인 경우가 있다.
이때는 worker들이 정상적으로 살아 있는지 확인 해야한다.
쿠버네티스의 마스터 노드는 단지 서비스를 관리하고 실행하는 역할이므로 실제 서비스는 worker노드에서 실행된다.
그래서 항상 worker노드가 정상적으로 실행이 되어 있어야만 서비스가 정상적으로 동작한다.

728x90
반응형