2025-01-17 in blog on Jenkins , github , Webhook
Jenkins + Github Web Hook
Jenkins k8s jenkins ngrok Jenkins k8s jenkins Find a jenkins pod w/ k8s pod, jenkins namespace kubectl get pod -n jenkins
NAME READY STATUS RESTARTS AGE
jenkins-6846f7864d-s92t8 1/1 Running 1 ( 22m ago) 41m
Login to jenkins pod kubectl -n jenkins exec -it jenkins-6846f7864d-s92t8 -- /bin/bash
create a ssh key-pair (privae, public) jenkins@jenkins-6846f7864d-s92t8:/$
jenkins@jenkins-6846f7864d-s92t8:/$ cd /var/jenkins_home
jenkins@jenkins-6846f7864d-s92t8:/$ mkdir .ssh
jenkins@jenkins-6846f7864d-s92t8:/$ cd .ssh
jenkins@jenkins-6846f7864d-s92t8:/$ ssh-keygen -t rsa -b 4096 -C test-key -f github_jenkins
Generating public/private rsa key pair.
Enter passphrase ( empty for no passphrase) :
Enter same passphrase again:
Your identification has been saved in github_jenkins
Your public key has been saved in github_jenkins.pub
The key fingerprint is:
SHA256:NJmTn59EOKF/7oLbcUqh1PCJUZ2f82tGL4t7bT8JEKg test-key
The key's randomart image is:
+---[RSA 4096]----+
| +. . |
| B +o |
| % o o. . |
| E @ * + |
| S O + o |
| . . * o ..|
| ..o = o.+|
| .o.= .o*+|
| ..o.+o+++|
+----[SHA256]-----+
jenkins@jenkins-6846f7864d-s92t8:~/.ssh$ ls
github_jenkins github_jenkins.pub
Register SSH key (public key) to Github Repositories
Goto github repositories (https://github.com/pushdown99/jenkins-test ) Settings > General/Security/Deploy keys => [Add deploy key
] Deploy keys/Add new => Title: github_jenkins, Key: (cat ithub_jenkins.pub) => [Add key
] Register SSH key (private key) to Jenkins Credentials
Goto Jenkins dashboard (ex: http://127.0.0.1:4377) Dashboard > + New Item
=> New Item / Name: github_jenkins
Type: Freestyle project
Dashboard > Name: github_jenkins
=> Source code management => Git/Repository URL: git@github.com:pushdown99/jenkins-test.git
, Credentials/ Add: Jenkins
=> Kind: SSH Username with private key
, Username: github_jenkins
, Private key/Enterdirectly: (cat ithub_jenkins) => [Add
] Build Trigger
Build Trigger / [v
] Github hook trigger for GITScm polling Plugin Installation
Jenkins Management > Plugins > Available plugins > GitHub Integration Plugin
: Install Ngrok Installation (optional: localhost)
choco install ngrok
ngrok config add-authtoken 46WbJVNrQ1pdq1mkbHAxT_ ( API secret )
ngrok http 4377
Forwarding https://4895-220-76-193-80.ngrok-free.app - > http://localhost:4377
Setting for Github Repository Webhook
Goto github repositories (https://github.com/pushdown99/jenkins-test ) Settings > General/Code and automation/Webhooks => Payload URL: https://4895-220-76-193-80.ngrok-free.app
/github-webhook/, Conntent type: application/json
, [v
] Just the push event, [v
] Active => []Update webhook
] ngrok 2025-01-15 in blog on K8s , Minikube
k8s Quick-Start with Minikube
minikube Installation / Dashboard ArgoCD Installation / Dashboard Get password (User: admin
) Harbor add repo fetch & unzip chart Installation MinIO deploying with ArgoCD git
repositoriesMinIO Application creation with ArgoCD git
repositoriesHOW-TO CI/CD with ArgoCD Sample Application with ArgoCD Jenkins Jenkins Installation with ArgoCD Nexus Nexus Installation with ArgoCD Top minikube Installation / Dashboard minikube start
minikube dashboard
ArgoCD Installation / Dashboard kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
minikube tunnel
minikube service argocd-server -n argocd
Get password (User: admin
) argocd admin initial-password -n argocd
Harbor add repo helm repo add harbor https://helm.goharbor.io
helm repo list
fetch & unzip chart helm fetch harbor/harbor
tar zxvf harbor-x.x.x.tgz
Download: values.yaml
expose type to loadBalancer
and tls disable
expose :
type : loadBalancer
ports :
httpPort : 80
tls :
enabled : false # true
Installation kubectl create ns hb
helm install harbor -f values.yaml . -n hb
minikube tunnel
browse to http://localhost
id: admin
, password: Harbor12345
MinIO deploying with ArgoCD git
repositorieshttps://github.com/pushdown99/argo-minio.git
app/k8s-deployment.yaml
apiVersion : apps/v1
kind : Deployment
metadata :
name : minio
spec :
replicas : 1
selector :
matchLabels :
app : minio
strategy :
type : Recreate
template :
metadata :
labels :
app : minio
spec :
volumes :
- name : storage
hostPath :
path : /data/minio
containers :
- name : minio
image : minio/minio:latest
args :
- server
- --console-address
- " :9001"
- " /storage"
env :
- name : MINIO_ROOT_USER
value : " minio"
- name : MINIO_ROOT_PASSWORD
value : " minio123"
- name : TZ
value : Asia/Seoul
- name : LANG
value : ko_KR.utf8
ports :
- containerPort : 9000
hostPort : 9000
- containerPort : 9001
hostPort : 9001
volumeMounts :
- name : storage
mountPath : " /storage"
---
apiVersion : v1
kind : Service
metadata :
name : minio
labels :
run : minio
spec :
type : NodePort
ports :
- port : 9000
targetPort : 9000
nodePort : 30333
name : api
- port : 9001
targetPort : 9001
nodePort : 30334
name : ui
selector :
app : minio
MinIO Application creation with ArgoCD git
repositorieshttps://github.com/pushdown99/argo-minio.git
app/k8s-deployment.yaml
apiVersion : apps/v1
kind : Deployment
metadata :
name : myweb
spec :
replicas : 2
selector :
matchLabels :
app : myweb
template :
metadata :
labels :
app : myweb
spec :
containers :
- name : myweb
image : pushdown99/myweb:latest
ports :
- containerPort : 3000
---
apiVersion : v1
kind : Service
metadata :
name : myweb-service
spec :
type : NodePort
selector :
app : myweb
ports :
- protocol : TCP
port : 3000
targetPort : 3000
nodePort : 30000
HOW-TO Login to ArgoCD Applications > + New APP
Fill-in
(GENERAL) Application Name: minio
(GENERAL) Project Name: default
(SOURCE) Repository URL: https://github.com/pushdown99/argo-minio.git
(SOURCE) Path: app
(DESTINATION) Cluster URL: https://kubernetes.default.svc
(DESTINATION) Namespace: default
Create
SYNC
kubectl
commandskubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 35m
minio NodePort 10.98.171.143 <none> 9000:30333/TCP,9001:30334/TCP 64s
kubectl port-forward svc/minio 9000:9000 9001:9001
browse to http://127.0.0.1:9000
id: minio
, password: minio123
CI/CD with ArgoCD Sample Application with ArgoCD https://github.com/pushdown99/cicd-node.git
app/k8s-deployment.yaml
apiVersion : apps/v1
kind : Deployment
metadata :
name : myweb
spec :
replicas : 2
selector :
matchLabels :
app : myweb
template :
metadata :
labels :
app : myweb
spec :
containers :
- name : myweb
image : pushdown99/myweb:latest
ports :
- containerPort : 3000
---
apiVersion : v1
kind : Service
metadata :
name : myweb-service
spec :
type : NodePort
selector :
app : myweb
ports :
- protocol : TCP
port : 3000
targetPort : 3000
nodePort : 30000
HOW-TO
Login to ArgoCD Applications > + New APP
Fill-in
(GENERAL) Application Name: myweb
(GENERAL) Project Name: default
(SOURCE) Repository URL: https://github.com/pushdown99/cicd-node.git
(SOURCE) Path: app
(DESTINATION) Cluster URL: https://kubernetes.default.svc
(DESTINATION) Namespace: default
Create
SYNC
kubectl
commandskubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 54m
minio NodePort 10.98.171.143 <none> 9000:30333/TCP,9001:30334/TCP 20m
myweb-service NodePort 10.104.220.233 <none> 3000:30000/TCP 14m
kubectl port-forward svc/myweb-service 3000:3000
browse to http://127.0.0.1:3000
Jenkins Jenkins Installation with ArgoCD https://github.com/pushdown99/argo-jenkins.git
HOW-TO
Login to ArgoCD Applications > + New APP
Fill-in
(GENERAL) Application Name: jenkins
(GENERAL) Project Name: default
(SOURCE) Repository URL: https://github.com/pushdown99/argo-jenkins.git
(SOURCE) Path: app
(DESTINATION) Cluster URL: https://kubernetes.default.svc
(DESTINATION) Namespace: default
Create
SYNC
kubectl
commandsminikube service jenkins-service -n jenkins
|-----------|-----------------|-------------|---------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|-----------------|-------------|---------------------------|
| jenkins | jenkins-service | 8080 | http://192.168.49.2:32000 |
|-----------|-----------------|-------------|---------------------------|
π jenkins-service μλΉμ€μ ν°λμ μμνλ μ€
|-----------|-----------------|-------------|------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|-----------------|-------------|------------------------|
| jenkins | jenkins-service | | http://127.0.0.1:44853 |
|-----------|-----------------|-------------|------------------------|
π Opening service jenkins/jenkins-service in default browser...
β windows μμ Docker λλΌμ΄λ²λ₯Ό μ¬μ©νκ³ μκΈ° λλ¬Έμ, ν°λ―Έλμ μ΄μ΄μΌ μ€νν μ μμ΅λλ€
Find password for access page http://127.0.0.1:44853
kubectl get pod -n jenkins
NAME READY STATUS RESTARTS AGE
jenkins-6846f7864d-957b8 1/1 Running 0 2m8s
kubectl -n jenkins exec -it jenkins-6846f7864d-957b8 -- /bin/bash
jenkins@jenkins-6846f7864d-957b8:/$ cat /var/jenkins_home/secrets/initialAdminPassword
browse to http://127.0.0.1:44853
Nexus Nexus Installation with ArgoCD https://github.com/pushdown99/argo-nexus.git
HOW-TO
Login to ArgoCD Applications > + New APP
Fill-in
(GENERAL) Application Name: nexus
(GENERAL) Project Name: default
(SOURCE) Repository URL: https://github.com/pushdown99/argo-nexus.git
(SOURCE) Path: app
(DESTINATION) Cluster URL: https://kubernetes.default.svc
(DESTINATION) Namespace: default
Create
SYNC
kubectl
commandsminikube service nexus-service -n nexus
|-----------|---------------|-------------|---------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|---------------|-------------|---------------------------|
| nexus | nexus-service | 8081 | http://192.168.49.2:30100 |
|-----------|---------------|-------------|---------------------------|
π nexus-service μλΉμ€μ ν°λμ μμνλ μ€
|-----------|---------------|-------------|------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|---------------|-------------|------------------------|
| nexus | nexus-service | | http://127.0.0.1:60009 |
|-----------|---------------|-------------|------------------------|
π Opening service nexus/nexus-service in default browser...
β windows μμ Docker λλΌμ΄λ²λ₯Ό μ¬μ©νκ³ μκΈ° λλ¬Έμ, ν°λ―Έλμ μ΄μ΄μΌ μ€νν μ μμ΅λλ€
Find password for access page http://127.0.0.1:60009
kubectl get pod -n nexus
NAME READY STATUS RESTARTS AGE
nexus-65b596bb55-rv47v 1/1 Running 0 5m34s
kubectl -n nexus exec -it nexus-65b596bb55-rv47v -- /bin/bash
bash-5.1$ cat /nexus-data/admin.password
browse to http://127.0.0.1:60009
Top kubectl top node
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
CI/CD with Minikube ArgoCD Installation CI/CD with Minikube ArgoCD Installation kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
kubectl get svc -n argocd
kubectl port-forward svc/argocd-server -n argocd 8080:443
Login
User: admin Password:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
PWzPW5Oa8me81UBr
> netstat -ano | findstr 8080
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 7588
TCP [::]:8080 [::]:0 LISTENING 7588
TCP [::1]:8080 [::1]:64187 ESTABLISHED 7588
TCP [::1]:8080 [::1]:64188 ESTABLISHED 7588
TCP [::1]:64187 [::1]:8080 ESTABLISHED 15888
TCP [::1]:64188 [::1]:8080 ESTABLISHED 15888
> tasklist /FI "PID eq 7588"
μ΄λ―Έμ§ μ΄λ¦ PID μΈμ
μ΄λ¦ μΈμ
# λ©λͺ¨λ¦¬ μ¬μ©
========================= ======== ================ =========== ============
java.exe 7588 Services 0 385,468 K
2025-01-06 in blog on K8s , Istio
Bookinfo Application, Istio