Continuous Integration with Jenkins
This example deploys a container running the Jenkins continuous integration system onto a running
Kubernetes cluster using Pulumi and @pulumi/kubernetes.
Running the App
Follow the steps in Pulumi Installation and Setup and Configuring Pulumi Kubernetes to get setup with Pulumi and 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.ts. See the Kubernetes Services docs for more details.
Install dependencies:
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install -r requirements.txtCreate a new stack:
$ pulumi stack init devCreate configuration keys for the root username and password for the Jenkins instance we are about to create:
$ pulumi config set username <your desired username>
$ pulumi config set password <your desired password> --secretConfigure Kubernetes to run without Minikube:
$ pulumi config set isMinikube falsePreview the deployment of the application:
$ pulumi preview
Previewing update of stack 'dev'
Type Name Status Info
* global global unchanged
Previewing changes:
Type Name Status Info
* global global no change
+ pulumi:pulumi:Stack kubernetes-py-jenkins-dev create
+ └─ jenkins:jenkins:Instance dev create
+ ├─ kubernetes:core:v1:Secret dev-secret create
+ ├─ kubernetes:core:v1:PersistentVolumeClaim dev-pvc create
+ ├─ kubernetes:core:v1:Service dev-service create
+ └─ kubernetes:extensions:v1beta1:Deployment dev-deploy create
info: 6 changes previewed:
+ 6 resources to createPerform the deployment:
$ pulumi up --skip-preview
Updating stack 'dev'
Type Name Status Info
* global global unchanged
Performing changes:
Type Name Status Info
* global global unchanged
+ pulumi:pulumi:Stack kubernetes-py-jenkins-dev created
+ └─ jenkins:jenkins:Instance dev created
+ ├─ kubernetes:core:v1:Secret dev-secret created
+ ├─ kubernetes:core:v1:PersistentVolumeClaim dev-pvc created
+ ├─ kubernetes:core:v1:Service dev-service created
+ └─ kubernetes:extensions:v1beta1:Deployment dev-deploy created
info: 6 changes performed:
+ 6 resources created
Update duration: 2m30.397621136sThe deployment is complete! Use kubectl to see the Service that we just deployed:
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dev LoadBalancer 10.43.241.251 35.230.56.127 80:30638/TCP,443:30204/TCP 3mThe Jenkins instance we just deployed is reachable through port 80 of the external IP address. You can now
visit http://35.230.56.127/jenkins/login in a Web browser to begin the first-install flow for your new Jenkins instance.
You can use the username and password that you saved in your Pulumi config to log in to your new Jenkins instance.
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.
When you’re ready to be done with Jenkins, you can destroy the instance:
$ pulumi destroy
Do you want to perform this destroy? yes
Destroying stack 'dev'
Performing changes:
Type Name Status Info
- pulumi:pulumi:Stack kubernetes-py-jenkins-dev deleted
- └─ jenkins:jenkins:Instance dev deleted
- ├─ kubernetes:extensions:v1beta1:Deployment dev-deploy deleted
- ├─ kubernetes:core:v1:Service dev-service deleted
- ├─ kubernetes:core:v1:PersistentVolumeClaim dev-pvc deleted
- └─ kubernetes:core:v1:Secret dev-secret deleted
info: 6 changes performed:
- 6 resources deleted
Update duration: 18.202009282s