Helm/Jenkins: Difference between revisions
Jump to navigation
Jump to search
| (29 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{|class='wikitable mw-collapsible' | |||
!scope='col' style='width:1000px'| | |||
Helm » Repo » Manage | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="bash"> | |||
helm repo add jenkins https://charts.jenkins.io | |||
helm repo update && helm repo list | |||
</syntaxhighlight> | |||
|} | |||
==Helm » K8s » Config== | |||
{|class='wikitable mw-collapsible' | |||
!scope='col' colspan='2' style='width:1000px'| | |||
Helm » K8s » Config | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="bash"> | |||
export KUBECONFIG=${HOME}/.kube/eks-kubeconfig.yaml | |||
export KUBECONFIG=${HOME}/.kube/gke-kubeconfig.yaml | |||
export KUBECONFIG=${HOME}/.kube/lke-kubeconfig.yaml | |||
</syntaxhighlight> | |||
|valign='top'| | |||
<syntaxhighlight lang="bash"> | |||
export KUBECONFIG=${HOME}/.kube/shahed-aa-kubeconfig.yaml | |||
export KUBECONFIG=${HOME}/.kube/shahed-ab-kubeconfig.yaml | |||
export KUBECONFIG=${HOME}/.kube/shahed-ac-kubeconfig.yaml | |||
</syntaxhighlight> | |||
|- | |||
|valign='top' colspan='2'| | |||
<syntaxhighlight lang="bash"> | |||
export KUBECONFIG=${HOME}/.kube/shahed-ae-kubeconfig.yaml | |||
kubectl config get-contexts | |||
kubectl config view | |||
</syntaxhighlight> | |||
|} | |||
==Helm » K8s » Storage== | |||
{|class='wikitable mw-collapsible' | |||
!scope='col' colspan='2' style='width:1000px'| | |||
Helm » K8s » Storage | |||
|- | |||
|valign='top' colspan='2'| | |||
<syntaxhighlight lang="bash" highlight='3,4'> | |||
cat << EXE | sudo bash | |||
mkdir -p /var/minikube/pvc/jenkins/data-jenkins-0/home/plugins/ | |||
rsync -avz ${HOME}/.config/jenkins/plugins/* \ | |||
/var/minikube/pvc/jenkins/data-jenkins-0/home/plugins/ | |||
chown -R 1000:1000 /var/minikube/pvc/jenkins/data-jenkins-0/ | |||
chmod -R 750 /var/minikube/pvc/jenkins/ | |||
EXE | |||
</syntaxhighlight> | |||
|- | |||
|valign='top' style='width:500px'| | |||
<syntaxhighlight lang="yaml" highlight="6,15"> | |||
cat <<'YML'| kubectl apply -f - | |||
--- | |||
apiVersion: v1 | |||
kind: PersistentVolume | |||
metadata: | |||
name: jenkins-data-jenkins-0 | |||
spec: | |||
capacity: | |||
storage: 50Gi | |||
accessModes: | |||
- ReadWriteOnce | |||
persistentVolumeReclaimPolicy: Retain | |||
storageClassName: hostpath | |||
hostPath: | |||
path: /var/hostpath_pv/jenkins/data-jenkins-0 | |||
type: DirectoryOrCreate | |||
YML | |||
</syntaxhighlight> | |||
|valign='top'| | |||
* [[Helm/Jenkins#Jenkins » Plugin|Find More 👉 Jenkins » Plugin]] | |||
---- | |||
* [[K8s/Storage#Storage » Mount|Find More 👉 Storage » Mount]] | |||
---- | |||
* [[K8s/Storage#Storage » Class » Hostpath|Find More 👉 Storage » Class » Hostpath]] | |||
---- | |||
* [[K8s/Storage#Storage » Persistent Volume|Find More 👉 Storage » Persistent Volume]] | |||
---- | |||
|} | |||
==Helm » Install== | |||
{|class='wikitable mw-collapsible mw-collapsed' | |||
!scope='col' colspan='2' style='width:1000px'| | |||
Helm » Install | |||
|- | |||
|valign='top' style='width:500px'| | |||
<syntaxhighlight lang="bash"> | |||
helm show values jenkins/jenkins --version=5.8.67|less | |||
helm show values jenkins/jenkins --version=5.8.68|less | |||
</syntaxhighlight> | |||
|valign='top'| | |||
<syntaxhighlight lang="bash"> | |||
kubectl create ns jenkins | |||
kubectl get ns|grep jenkins | |||
</syntaxhighlight> | |||
|- | |||
|valign='top' colspan='2'| | |||
<syntaxhighlight lang="bash"> | |||
cat <<ENV | kubectl -n jenkins create secret generic jenkins --from-env-file=/dev/stdin | |||
admin-username=admin | |||
admin-password=sadaqah! | |||
ENV | |||
</syntaxhighlight> | |||
---- | |||
<syntaxhighlight lang="bash"> | |||
cat <<ENV | kubectl -n jenkins create secret generic credentials --from-env-file=/dev/stdin | |||
github-username=admin | |||
github-password=sadaqah! | |||
ENV | |||
</syntaxhighlight> | |||
---- | |||
<syntaxhighlight lang="bash"> | |||
JENKINS_INIT_SCRIPTS=$(mktemp -d) | |||
cat <<'EXE'| tee ${JENKINS_INIT_SCRIPTS}/01-print-users.groovy >/dev/null | |||
import jenkins.model.Jenkins | |||
import hudson.security.HudsonPrivateSecurityRealm | |||
def realm = Jenkins.instance.getSecurityRealm() | |||
if (realm instanceof HudsonPrivateSecurityRealm) { | |||
println ">> Listing users in HudsonPrivateSecurityRealm:" | |||
realm.getAllUsers().each { | |||
println "- ${it.id}" | |||
} | |||
} else if (realm.class.simpleName == 'SecurityRealm$None') { | |||
println ">> Security is not enabled. No user database is available." | |||
} else { | |||
println ">> Security realm is: ${realm.getClass().getName()}, user listing may not be supported." | |||
} | |||
EXE | |||
cat <<'EXE'| tee ${JENKINS_INIT_SCRIPTS}/02-print-plugins.groovy >/dev/null | |||
import jenkins.model.Jenkins | |||
import hudson.PluginWrapper | |||
println ">> Installed plugins:" | |||
Jenkins.instance.pluginManager.plugins.each { | |||
println "- ${it.getShortName()} (${it.getVersion()})" | |||
} | |||
EXE | |||
== | kubectl -n jenkins create configmap jenkins-init --from-file=${JENKINS_INIT_SCRIPTS} | ||
<syntaxhighlight lang=" | rm -rf ${JENKINS_INIT_SCRIPTS} | ||
</syntaxhighlight> | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="yaml"> | |||
cat <<'YML'| kubectl apply -n jenkins -f - | |||
--- | |||
apiVersion: v1 | |||
kind: PersistentVolumeClaim | |||
metadata: | |||
name: data-jenkins-0 | |||
namespace: jenkins | |||
labels: | |||
app.kubernetes.io/name: jenkins | |||
app.kubernetes.io/version: 1.0.0 | |||
app.kubernetes.io/instance: jenkins | |||
app.kubernetes.io/managed-by: kubectl | |||
spec: | |||
accessModes: | |||
- ReadWriteOnce | |||
resources: | |||
requests: | |||
storage: 50Gi | |||
storageClassName: hostpath | |||
volumeName: jenkins-data-jenkins-0 | |||
YML | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== | |valign='top'| | ||
[[K8s/Storage#Storage » Mount|Find More 👉 Storage » Mount]] | |||
---- | |||
[[K8s/Storage#Storage » Class » Hostpath|Find More 👉 Storage » Class » Hostpath]] | |||
---- | |||
[[K8s/Storage#Storage » Persistent Volume|Find More 👉 Storage » Persistent Volume]] | |||
---- | |||
|- | |||
|valign='top' colspan='2'| | |||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
cat <<YML | helm -n jenkins install jenkins jenkins/jenkins --version=5.8.68 -f - | |||
--- | |||
cat <<YML | helm | |||
controller: | controller: | ||
componentName: jenkins-controller | |||
image: | |||
tag: 2.504.3 | |||
tagLabel: jdk21 | |||
pullPolicy: IfNotPresent | |||
disableRememberMe: false | |||
numExecutors: 5 | |||
jenkinsUrl: https://jenkins.shahed.biz | |||
jenkinsAdminEmail: tool.tech@shahed.biz | |||
resources: | |||
limits: | |||
cpu: 2000m | |||
memory: 4Gi | |||
requests: | |||
cpu: 50m | |||
memory: 256Mi | |||
initContainerResources: | |||
limits: | |||
cpu: 2000m | |||
memory: 4Gi | |||
requests: | |||
cpu: 50m | |||
memory: 256Mi | |||
agentListenerPort: 50000 | |||
agentListenerEnabled: true | |||
agentListenerLoadBalancerSourceRanges: | |||
- 10.19.83.0/24 | |||
- 10.20.40.0/24 | |||
- 10.20.41.0/24 | |||
- 192.168.49.0/24 | |||
agentListenerServiceType: LoadBalancer | |||
agentListenerLoadBalancerIP: 192.168.49.104 | |||
loadBalancerSourceRanges: | |||
- 10.19.83.0/24 | |||
- 10.20.40.0/24 | |||
- 10.20.41.0/24 | |||
- 192.168.49.0/24 | |||
loadBalancerIP: 192.168.49.104 | |||
installPlugins: false | installPlugins: false | ||
ingress: | ingress: | ||
enabled: true | enabled: true | ||
ingressClassName: nginx | |||
hostName: jenkins.shahed.biz | |||
persistence: | |||
size: 50Gi | |||
enabled: true | |||
subPath: home | |||
storageClass: hostpath | |||
accessMode: ReadWriteOnce | |||
existingClaim: data-jenkins-0 | |||
YML | YML | ||
</syntaxhighlight> | |||
|} | |||
==Helm » K8s » Verify== | |||
{|class='wikitable mw-collapsible' | |||
!scope='col' colspan='2' style='width:1000px'| | |||
Helm » K8s » Verify | |||
|- | |||
|valign='top' colspan='2'| | |||
<syntaxhighlight lang="bash"> | |||
kubectl -n jenkins exec -i svc/jenkins -c jenkins -- cat /run/secrets/additional/chart-admin-password && echo | |||
xdg-open https://www.cdn77.com/tls-test/result?domain=jenkins.shahed.biz | |||
xdg-open https://jenkins.shahed.biz | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== | |- | ||
|valign='top' style='width:600px'| | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl -n jenkins logs -f svc/jenkins -c config-reload-init | |||
kubectl | kubectl -n jenkins logs -f svc/jenkins -c config-reload | ||
kubectl -n jenkins logs -f svc/jenkins -c jenkins | |||
kubectl -n jenkins logs -f svc/jenkins -c init | |||
</syntaxhighlight> | |||
|valign='top'| | |||
<syntaxhighlight lang="yaml"> | |||
--- | |||
Page: https://jenkins.shahed.biz | |||
user: tool.tech@shahed.biz | |||
pass: sadaqah! | |||
</syntaxhighlight> | |||
|} | |||
==Helm » K8s » Scaling== | |||
{|class='wikitable mw-collapsible' | |||
!scope='col' style='width:1000px'| | |||
Helm » K8s » Scaling | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="yaml"> | |||
cat <<YML | \ | |||
kubectl -n jenkins patch sts/jenkins --patch-file=/dev/stdin | |||
--- | |||
spec: | |||
replicas: 0 | |||
YML | |||
</syntaxhighlight> | |||
---- | |||
<syntaxhighlight lang="yaml"> | |||
cat <<YML | \ | |||
kubectl -n jenkins patch sts/jenkins --patch-file=/dev/stdin | |||
--- | |||
spec: | |||
replicas: 1 | |||
YML | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
== | ==Helm » Uninstall== | ||
{| | {|class='wikitable mw-collapsible mw-collapsed' | ||
| valign= | !scope='col' colspan='2' style='width:1000px'| | ||
Helm » Uninstall | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
helm | helm uninstall jenkins -n jenkins | ||
kubectl delete pvc --all -n jenkins | |||
kubectl delete pv jenkins-data-jenkins-0 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| valign= | |valign='top'| | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl | kubectl delete deploy --all -n jenkins | ||
kubectl | kubectl delete all --all -n jenkins | ||
kubectl | kubectl delete namespace jenkins | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
==Jenkins » Plugin== | |||
{|class='wikitable mw-collapsible' | |||
!scope='col' colspan='2' style='width:1000px'| | |||
Jenkins » Plugin » Manager | |||
|- | |- | ||
| colspan=" | |valign='top' colspan='2'| | ||
<syntaxhighlight lang="bash"> | |||
sudo apt-get install -y openjdk-21-jdk | |||
mkdir -p ~/.config/jenkins/ | |||
cd ~/.config/jenkins/ | |||
</syntaxhighlight> | |||
---- | ---- | ||
<syntaxhighlight lang="bash"> | |||
cat <<'EXE'| bash | |||
if [[ ! -f './jenkins-plugin-manager-2.13.2.jar' ]];then wget -cq https://github.com/jenkinsci/\ | |||
plugin-installation-manager-tool/releases/download/2.13.2/jenkins-plugin-manager-2.13.2.jar -P .;fi | |||
EXE | |||
</syntaxhighlight> | |||
|- | |- | ||
| valign= | |valign='top'| | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cat <<'JPI'| tee ./plugins.txt >/dev/null | |||
git:latest | |||
dark-theme:latest | |||
kubernetes:latest | |||
octopusdeploy:latest | |||
workflow-aggregator:latest | |||
configuration-as-code:latest | |||
JPI | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| valign="top" | | | valign="top" | | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
alias jenkins-plugin-cli="$(cat << EOF | |||
mkdir -p ./plugins/;/usr/lib/jvm/java-21-openjdk-amd64/bin/java \ | |||
-jar jenkins-plugin-manager-2.13.2.jar -d ./plugins \ | |||
-f ./plugins.txt --jenkins-version=2.504.3 --verbose | |||
EOF | |||
)" | |||
jenkins-plugin-cli | |||
</syntaxhighlight> | |||
|- | |||
|valign='top' colspan='2'| | |||
<syntaxhighlight lang="bash" highlight='3,4'> | |||
cat << EXE | sudo bash | |||
mkdir -p /var/minikube/pvc/jenkins/data-jenkins-0/home/plugins/ | |||
rsync -avz ${HOME}/.config/jenkins/plugins/* \ | |||
/var/minikube/pvc/jenkins/data-jenkins-0/home/plugins/ | |||
chown -R 1000:1000 /var/minikube/pvc/jenkins/data-jenkins-0/ | |||
chmod -R 750 /var/minikube/pvc/jenkins/ | |||
EXE | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
==Playground== | |||
{|class='wikitable mw-collapsible mw-collapsed' | |||
!scope='col' colspan='2' style='width:1000px'| | |||
Playground | |||
|- | |- | ||
| colspan=" | |valign='top' colspan='2'| | ||
<syntaxhighlight lang="bash"> | |||
helm -n jenkins install jenkins jenkins/jenkins --version=5.8.67 | |||
helm -n jenkins upgrade -i jenkins jenkins/jenkins --version=5.8.68 | |||
helm show values jenkins/jenkins --version=5.8.68|less | |||
</syntaxhighlight> | |||
---- | ---- | ||
<syntaxhighlight lang="bash"> | |||
kubectl -n jenkins get secret jenkins -o json|jq -r '.data."jenkins-admin-password"'|base64 -d;echo | |||
kubectl -n jenkins get secret jenkins -o json|jq -r '.data."jenkins-admin-user"' |base64 -d;echo | |||
kubectl -n jenkins exec -it svc/jenkins -c config-reload -- id | |||
kubectl -n jenkins exec -it svc/jenkins -c jenkins -- id | |||
kubectl -n jenkins logs -f svc/jenkins -c config-reload-init | |||
kubectl -n jenkins logs -f svc/jenkins -c config-reload | |||
kubectl -n jenkins logs -f svc/jenkins -c jenkins | |||
kubectl -n jenkins logs -f svc/jenkins -c init | |||
</syntaxhighlight> | |||
|- | |- | ||
|valign='top'| | |||
<syntaxhighlight lang="bash"> | |||
kubectl -n jenkins delete all --all | |||
kubectl -n jenkins delete ing --all | |||
kubectl -n jenkins delete sts --all | |||
</syntaxhighlight> | |||
| valign="top" | | | valign="top" | | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl | kubectl delete pv jenkins-data-jenkins-0 | ||
kubectl | kubectl -n jenkins delete svc --all | ||
kubectl | kubectl -n jenkins delete pvc --all | ||
kubectl | </syntaxhighlight> | ||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="bash"> | |||
kubectl -n jenkins rollout history sts jenkins | |||
kubectl -n jenkins rollout restart sts jenkins | |||
kubectl -n jenkins rollout status sts jenkins | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| valign="top" | | | valign="top" | | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl | kubectl -n jenkins logs -f svc/jenkins -c config-reload | ||
kubectl -n jenkins logs -f svc/jenkins -c jenkins | |||
kubectl | kubectl -n jenkins logs -f svc/jenkins -c init | ||
kubectl | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |} | ||
==References== | ==References== | ||
{| | {|class='wikitable mw-collapsible mw-collapsed' | ||
| valign= | !scope='col' colspan='3' style='width:1000px'| | ||
* [ | References | ||
|- | |||
|valign='top'| | |||
* [[Helm/Prometheus Stack|Helm » Prometheus Stack]] | |||
* [https://octopus.com/blog/jenkins-helm-install-guide Helm » Jenkins » Install] | * [https://octopus.com/blog/jenkins-helm-install-guide Helm » Jenkins » Install] | ||
* [[Helm/Cert Manager|Helm » Cert Manager]] | |||
* [https://artifacthub.io/packages/helm/jenkinsci/jenkins Helm » Jenkins] | * [https://artifacthub.io/packages/helm/jenkinsci/jenkins Helm » Jenkins] | ||
* [[Helm/Sign|Helm » Sign]] | |||
* [[Helm]] | * [[Helm]] | ||
| valign="top" | | | valign="top" | | ||
* [https://plugins.jenkins.io/configuration-as-code/releases/ Jenkins » Plugins » Configuration As Code] | |||
* [https://plugins.jenkins.io/workflow-aggregator/releases/ Jenkins » Plugins » Workflow Aggregator] | |||
* [https://plugins.jenkins.io/octopusdeploy/releases/ Jenkins » Plugins » Octopus Deploy] | |||
* [https://plugins.jenkins.io/kubernetes/releases/ Jenkins » Plugins » Kubernetes] | |||
* [https://plugins.jenkins.io/git/releases/ Jenkins » Plugins » Git] | |||
* [[Jenkins]] | * [[Jenkins]] | ||
| valign="top" | | | valign="top" | | ||
* [https://plugins.jenkins.io/dark-theme/releases/ Jenkins » Plugins » Dark Theme] | |||
* [https://github.com/jenkinsci/plugin-installation-manager-tool/releases/ Jenkins » Plugins Manager Tool] | |||
* [[Security/Password|Security » Password]] | |||
|- | |- | ||
| valign= | |valign='top'| | ||
* [ | * [[Linux Containers]] | ||
* [[Kubernetes]] | * [[Kubernetes]] | ||
* [[Multipass]] | |||
* [[Minikube]] | * [[Minikube]] | ||
* [[ | * [[Podman]] | ||
* [[ | * [[Vagrant]] | ||
* [[Docker]] | |||
* [[Qemu]] | |||
* [[K9s]] | |||
* [[K8s]] | * [[K8s]] | ||
| valign= | |valign='top'| | ||
* [[Minikube Ingress DNS|Minikube » Ingress » DNS]] | |||
| | * [[Minikube Systemd|Minikube » Systemd]] | ||
* [[Minikube Registry|Minikube » Registry]] | |||
* [[Minikube MetalLB|Minikube » MetalLB]] | |||
* [[Minikube Tunnel|Minikube » Tunnel]] | |||
* [[Kubectl]] | |||
* [[Ansible]] | |||
* [[CIDR]] | |||
* [[Helm]] | |||
* [[UFW]] | |||
|valign='top'| | |||
* [[K8s/HAProxy/Ingress|K8s » HAProxy » Ingress]] | |||
* [[Minikube Ingress DNS|K8s » Ingress » DNS]] | |||
* [[K8s/Swiss Knife|K8s » Swiss Knife]] | |||
* [[K8s/PgBouncer|K8s » PgBouncer]] | |||
* [[K8s/Storage|K8s » Storage]] | |||
* [[K8s/Ingress|K8s » Ingress]] | |||
* [[K8s/Service|K8s » Service]] | |||
* [[K8s/Secret|K8s » Secret]] | |||
* [[K8s/N8N|K8s » N8N]] | |||
* [[K8s/Run|K8s » Run]] | |||
|} | |} | ||
Latest revision as of 03:25, 15 July 2025
|
Helm » Repo » Manage |
|---|
helm repo add jenkins https://charts.jenkins.io
helm repo update && helm repo list
|
Helm » K8s » Config
|
Helm » K8s » Config | |
|---|---|
export KUBECONFIG=${HOME}/.kube/eks-kubeconfig.yaml
export KUBECONFIG=${HOME}/.kube/gke-kubeconfig.yaml
export KUBECONFIG=${HOME}/.kube/lke-kubeconfig.yaml
|
export KUBECONFIG=${HOME}/.kube/shahed-aa-kubeconfig.yaml
export KUBECONFIG=${HOME}/.kube/shahed-ab-kubeconfig.yaml
export KUBECONFIG=${HOME}/.kube/shahed-ac-kubeconfig.yaml
|
export KUBECONFIG=${HOME}/.kube/shahed-ae-kubeconfig.yaml
kubectl config get-contexts
kubectl config view
| |
Helm » K8s » Storage
|
Helm » K8s » Storage | |
|---|---|
cat << EXE | sudo bash
mkdir -p /var/minikube/pvc/jenkins/data-jenkins-0/home/plugins/
rsync -avz ${HOME}/.config/jenkins/plugins/* \
/var/minikube/pvc/jenkins/data-jenkins-0/home/plugins/
chown -R 1000:1000 /var/minikube/pvc/jenkins/data-jenkins-0/
chmod -R 750 /var/minikube/pvc/jenkins/
EXE
| |
cat <<'YML'| kubectl apply -f -
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: jenkins-data-jenkins-0
spec:
capacity:
storage: 50Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: hostpath
hostPath:
path: /var/hostpath_pv/jenkins/data-jenkins-0
type: DirectoryOrCreate
YML
|
|
Helm » Install
|
Helm » Install | |
|---|---|
helm show values jenkins/jenkins --version=5.8.67|less
helm show values jenkins/jenkins --version=5.8.68|less
|
kubectl create ns jenkins
kubectl get ns|grep jenkins
|
cat <<ENV | kubectl -n jenkins create secret generic jenkins --from-env-file=/dev/stdin
admin-username=admin
admin-password=sadaqah!
ENV
cat <<ENV | kubectl -n jenkins create secret generic credentials --from-env-file=/dev/stdin
github-username=admin
github-password=sadaqah!
ENV
JENKINS_INIT_SCRIPTS=$(mktemp -d)
cat <<'EXE'| tee ${JENKINS_INIT_SCRIPTS}/01-print-users.groovy >/dev/null
import jenkins.model.Jenkins
import hudson.security.HudsonPrivateSecurityRealm
def realm = Jenkins.instance.getSecurityRealm()
if (realm instanceof HudsonPrivateSecurityRealm) {
println ">> Listing users in HudsonPrivateSecurityRealm:"
realm.getAllUsers().each {
println "- ${it.id}"
}
} else if (realm.class.simpleName == 'SecurityRealm$None') {
println ">> Security is not enabled. No user database is available."
} else {
println ">> Security realm is: ${realm.getClass().getName()}, user listing may not be supported."
}
EXE
cat <<'EXE'| tee ${JENKINS_INIT_SCRIPTS}/02-print-plugins.groovy >/dev/null
import jenkins.model.Jenkins
import hudson.PluginWrapper
println ">> Installed plugins:"
Jenkins.instance.pluginManager.plugins.each {
println "- ${it.getShortName()} (${it.getVersion()})"
}
EXE
kubectl -n jenkins create configmap jenkins-init --from-file=${JENKINS_INIT_SCRIPTS}
rm -rf ${JENKINS_INIT_SCRIPTS}
| |
cat <<'YML'| kubectl apply -n jenkins -f -
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-jenkins-0
namespace: jenkins
labels:
app.kubernetes.io/name: jenkins
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: jenkins
app.kubernetes.io/managed-by: kubectl
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
storageClassName: hostpath
volumeName: jenkins-data-jenkins-0
YML
|
Find More 👉 Storage » Class » Hostpath Find More 👉 Storage » Persistent Volume |
cat <<YML | helm -n jenkins install jenkins jenkins/jenkins --version=5.8.68 -f -
---
controller:
componentName: jenkins-controller
image:
tag: 2.504.3
tagLabel: jdk21
pullPolicy: IfNotPresent
disableRememberMe: false
numExecutors: 5
jenkinsUrl: https://jenkins.shahed.biz
jenkinsAdminEmail: tool.tech@shahed.biz
resources:
limits:
cpu: 2000m
memory: 4Gi
requests:
cpu: 50m
memory: 256Mi
initContainerResources:
limits:
cpu: 2000m
memory: 4Gi
requests:
cpu: 50m
memory: 256Mi
agentListenerPort: 50000
agentListenerEnabled: true
agentListenerLoadBalancerSourceRanges:
- 10.19.83.0/24
- 10.20.40.0/24
- 10.20.41.0/24
- 192.168.49.0/24
agentListenerServiceType: LoadBalancer
agentListenerLoadBalancerIP: 192.168.49.104
loadBalancerSourceRanges:
- 10.19.83.0/24
- 10.20.40.0/24
- 10.20.41.0/24
- 192.168.49.0/24
loadBalancerIP: 192.168.49.104
installPlugins: false
ingress:
enabled: true
ingressClassName: nginx
hostName: jenkins.shahed.biz
persistence:
size: 50Gi
enabled: true
subPath: home
storageClass: hostpath
accessMode: ReadWriteOnce
existingClaim: data-jenkins-0
YML
| |
Helm » K8s » Verify
|
Helm » K8s » Verify | |
|---|---|
kubectl -n jenkins exec -i svc/jenkins -c jenkins -- cat /run/secrets/additional/chart-admin-password && echo
xdg-open https://www.cdn77.com/tls-test/result?domain=jenkins.shahed.biz
xdg-open https://jenkins.shahed.biz
| |
kubectl -n jenkins logs -f svc/jenkins -c config-reload-init
kubectl -n jenkins logs -f svc/jenkins -c config-reload
kubectl -n jenkins logs -f svc/jenkins -c jenkins
kubectl -n jenkins logs -f svc/jenkins -c init
|
---
Page: https://jenkins.shahed.biz
user: tool.tech@shahed.biz
pass: sadaqah!
|
Helm » K8s » Scaling
|
Helm » K8s » Scaling |
|---|
cat <<YML | \
kubectl -n jenkins patch sts/jenkins --patch-file=/dev/stdin
---
spec:
replicas: 0
YML
cat <<YML | \
kubectl -n jenkins patch sts/jenkins --patch-file=/dev/stdin
---
spec:
replicas: 1
YML
|
Helm » Uninstall
|
Helm » Uninstall | |
|---|---|
helm uninstall jenkins -n jenkins
kubectl delete pvc --all -n jenkins
kubectl delete pv jenkins-data-jenkins-0
|
kubectl delete deploy --all -n jenkins
kubectl delete all --all -n jenkins
kubectl delete namespace jenkins
|
Jenkins » Plugin
|
Jenkins » Plugin » Manager | |
|---|---|
sudo apt-get install -y openjdk-21-jdk
mkdir -p ~/.config/jenkins/
cd ~/.config/jenkins/
cat <<'EXE'| bash
if [[ ! -f './jenkins-plugin-manager-2.13.2.jar' ]];then wget -cq https://github.com/jenkinsci/\
plugin-installation-manager-tool/releases/download/2.13.2/jenkins-plugin-manager-2.13.2.jar -P .;fi
EXE
| |
cat <<'JPI'| tee ./plugins.txt >/dev/null
git:latest
dark-theme:latest
kubernetes:latest
octopusdeploy:latest
workflow-aggregator:latest
configuration-as-code:latest
JPI
|
alias jenkins-plugin-cli="$(cat << EOF
mkdir -p ./plugins/;/usr/lib/jvm/java-21-openjdk-amd64/bin/java \
-jar jenkins-plugin-manager-2.13.2.jar -d ./plugins \
-f ./plugins.txt --jenkins-version=2.504.3 --verbose
EOF
)"
jenkins-plugin-cli
|
cat << EXE | sudo bash
mkdir -p /var/minikube/pvc/jenkins/data-jenkins-0/home/plugins/
rsync -avz ${HOME}/.config/jenkins/plugins/* \
/var/minikube/pvc/jenkins/data-jenkins-0/home/plugins/
chown -R 1000:1000 /var/minikube/pvc/jenkins/data-jenkins-0/
chmod -R 750 /var/minikube/pvc/jenkins/
EXE
| |
Playground
|
Playground | |
|---|---|
helm -n jenkins install jenkins jenkins/jenkins --version=5.8.67
helm -n jenkins upgrade -i jenkins jenkins/jenkins --version=5.8.68
helm show values jenkins/jenkins --version=5.8.68|less
kubectl -n jenkins get secret jenkins -o json|jq -r '.data."jenkins-admin-password"'|base64 -d;echo
kubectl -n jenkins get secret jenkins -o json|jq -r '.data."jenkins-admin-user"' |base64 -d;echo
kubectl -n jenkins exec -it svc/jenkins -c config-reload -- id
kubectl -n jenkins exec -it svc/jenkins -c jenkins -- id
kubectl -n jenkins logs -f svc/jenkins -c config-reload-init
kubectl -n jenkins logs -f svc/jenkins -c config-reload
kubectl -n jenkins logs -f svc/jenkins -c jenkins
kubectl -n jenkins logs -f svc/jenkins -c init
| |
kubectl -n jenkins delete all --all
kubectl -n jenkins delete ing --all
kubectl -n jenkins delete sts --all
|
kubectl delete pv jenkins-data-jenkins-0
kubectl -n jenkins delete svc --all
kubectl -n jenkins delete pvc --all
|
kubectl -n jenkins rollout history sts jenkins
kubectl -n jenkins rollout restart sts jenkins
kubectl -n jenkins rollout status sts jenkins
|
kubectl -n jenkins logs -f svc/jenkins -c config-reload
kubectl -n jenkins logs -f svc/jenkins -c jenkins
kubectl -n jenkins logs -f svc/jenkins -c init
|
References
|
References | ||
|---|---|---|