-
-
Save yogeek/b2fd2cbed84140f2269b05e14926a4b2 to your computer and use it in GitHub Desktop.
kubernetes_jenkins_configuration-as-code-plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
minikube start | |
minikube dashboard | |
# cd to dir with the supporting k8s/docker files | |
cd ~/sample/k8s-jenkins-casc/ | |
eval $(minikube docker-env) | |
docker build -t sample/jenkins:2.143 . | |
kubectl apply -f jenkins.yml | |
# get http address for jenkins | |
echo $(minikube ip):$(kubectl get services/jenkins -o jsonpath='{.spec.ports[0].nodePort}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cd to dir with the supporting k8s/docker files | |
cd ~/sample/k8s-jenkins-casc/ | |
kubectl delete -f jenkins.yml | |
docker rmi sample/jenkins:2.143 | |
minikube stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jenkins/jenkins:2.143 | |
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt | |
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: ServiceAccount | |
metadata: | |
name: jenkins | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: Role | |
metadata: | |
name: jenkins | |
rules: | |
- apiGroups: [""] | |
resources: ["pods"] | |
verbs: ["create","delete","get","list","patch","update","watch"] | |
- apiGroups: [""] | |
resources: ["pods/exec"] | |
verbs: ["create","delete","get","list","patch","update","watch"] | |
- apiGroups: [""] | |
resources: ["pods/log"] | |
verbs: ["get","list","watch"] | |
- apiGroups: [""] | |
resources: ["secrets"] | |
verbs: ["get"] | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: RoleBinding | |
metadata: | |
name: jenkins | |
roleRef: | |
apiGroup: rbac.authorization.k8s.io | |
kind: Role | |
name: jenkins | |
subjects: | |
- kind: ServiceAccount | |
name: jenkins | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: jenkins-configuration-as-code | |
data: | |
configuration-as-code.yml: | | |
jenkins: | |
systemMessage: "Welcome to Jenkins - configured with code!" | |
mode: EXCLUSIVE | |
numExecutors: 3 | |
location: | |
url: "http://192.168.99.100:30123/" | |
clouds: | |
- kubernetes: | |
name: "kubernetes" | |
serverUrl: "https://192.168.99.100:8443/" | |
jenkinsUrl: "http://172.17.0.6:8080/" | |
templates: | |
- name: "jenkins-slave" | |
label: "jenkins-slave" | |
containers: | |
- name: "jenkins-slave" | |
image: "jenkinsci/jnlp-slave:latest" | |
workingDir: "/home/jenkins" | |
ttyEnabled: true | |
command: "/bin/sh -c" | |
args: "cat" | |
nodeUsageMode: "NORMAL" | |
tool: | |
git: | |
installations: | |
- home: "git" | |
name: "Default" | |
jobs: | |
- script: > | |
pipelineJob('configuration-as-code') { | |
pineline { | |
stages { | |
stage("Deploy") { | |
sh 'sleep 30' | |
} | |
} | |
} | |
} | |
--- | |
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: jenkins | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
name: jenkins | |
labels: | |
name: jenkins | |
spec: | |
serviceAccountName: jenkins | |
containers: | |
- name: jenkins | |
image: sample/jenkins:2.143 | |
env: | |
- name: JAVA_OPTS | |
value: -Djenkins.install.runSetupWizard=false -Dhudson.slaves.NodeProvisioner.initialDelay=0 | |
- name: CASC_JENKINS_CONFIG | |
value: /var/jenkins_config/configuration-as-code.yml | |
ports: | |
- name: http-port | |
containerPort: 8080 | |
- name: jnlp-port | |
containerPort: 50000 | |
volumeMounts: | |
- name: jenkins-home | |
mountPath: /var/jenkins_home | |
- name: jenkins-configuration-as-code | |
mountPath: /var/jenkins_config | |
livenessProbe: | |
httpGet: | |
path: / | |
port: 8080 | |
initialDelaySeconds: 60 | |
timeoutSeconds: 5 | |
readinessProbe: | |
httpGet: | |
path: / | |
port: 8080 | |
initialDelaySeconds: 60 | |
timeoutSeconds: 5 | |
volumes: | |
- name: jenkins-home | |
emptyDir: {} | |
- name: jenkins-configuration-as-code | |
configMap: | |
name: jenkins-configuration-as-code | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: jenkins | |
spec: | |
type: NodePort | |
ports: | |
- port: 8080 | |
targetPort: 8080 | |
nodePort: 30123 | |
protocol: TCP | |
selector: | |
name: jenkins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timestamper:latest | |
command-launcher:latest | |
jdk-tool:latest | |
ssh-slaves:latest | |
kubernetes:latest | |
workflow-aggregator:latest | |
configuration-as-code:latest | |
configuration-as-code-support:latest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment