Continuous integration with Jenkins
Jenkins deployment on Kubernetes
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set kubernetes-py-jenkinscd pulumi-examples/kubernetes-py-jenkinsThis example deploys a container running the Jenkins continuous integration system onto a running
Kubernetes cluster using Pulumi and @pulumi/kubernetes.
Note: The code in this repo assumes you are deploying to a cluster that supports the
LoadBalancerservice type. This includes most cloud providers as well as Docker for Mac Edge w/ Kubernetes. If not (for example if you are targetingminikubeor your own custom Kubernetes cluster), replacetype: "LoadBalancer"withtype: "ClusterIP"injenkins.py. See the Kubernetes Services docs for more details.
Prerequisites#
Deploying the example#
-
Create a new stack:
Terminal window pulumi stack init dev -
Set the root username and password for the Jenkins instance you are about to create:
Terminal window pulumi config set username <your desired username>pulumi config set password <your desired password> --secret -
Configure Kubernetes to run without minikube:
Terminal window pulumi config set isMinikube false -
Install dependencies:
Terminal window python3 -m venv venvsource venv/bin/activatepip install -r requirements.txt -
Deploy the stack:
Terminal window pulumi upUpdating (dev):Type Name Status+ pulumi:pulumi:Stack kubernetes-py-jenkins-dev created+ └─ jenkins:jenkins:Instance dev created+ ├─ kubernetes:core:PersistentVolumeClaim dev-pvc created+ ├─ kubernetes:core:Service dev-service created+ ├─ kubernetes:core:Secret dev-secret created+ └─ kubernetes:apps:Deployment dev-deploy createdOutputs:external_ip: "35.239.72.50"Resources:+ 6 createdDuration: 1m57s -
The deployment is complete! Use
pulumi stack output external_ipto see the IP of the service you just deployed:Terminal window pulumi stack output external_ip35.239.72.50The Jenkins instance is reachable through port 80 of the external IP address. You can now visit
http://35.239.72.50/loginin a web browser to begin the first-install flow for your new Jenkins instance. Use the username and password that you saved in your Pulumi config to log in.Note: If you are deploying to a cluster that does not support
type: "LoadBalancer", and deployed the example usingtype: "ClusterIP"instead, runkubectl port-forward svc/jenkins 8080:80to forward the cluster port to the local machine and access the service vialocalhost:8080.
Cleaning up#
Once you’re finished experimenting, you can destroy your stack and remove it to avoid incurring any additional cost:
pulumi destroypulumi stack rm