-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeployJenkinsonKubernetes
More file actions
69 lines (55 loc) · 1.94 KB
/
Copy pathDeployJenkinsonKubernetes
File metadata and controls
69 lines (55 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
The Nautilus DevOps team is planning to set up a Jenkins CI server to create/manage some deployment pipelines for some of the projects.
They want to set up the Jenkins server on Kubernetes cluster.
Below you can find more details about the task:
1) Create a namespace jenkins
2) Create a Service for jenkins deployment. Service name should be jenkins-service under jenkins namespace, type should be NodePort, nodePort should be 30008
3) Create a Jenkins Deployment under jenkins namespace, It should be name as jenkins-deployment , labels app should be jenkins , container name should be jenkins-container , use jenkins/jenkins image , containerPort should be 8080 and replicas count should be 1.
SOLUTIONS
Created a namespace using the name "jenkins"
# kubectl create namespace jenkins
#kubectl get namespace ---- To verify if the namespace was actually created.
I changed the namespace environment from default to jenkins namespace
# kubectl config set-context $(kubectl config current-context) --namespace=jenkins
Creat Service with the given parameters
---
apiVersion: v1
kind: Service
metadata:
name: jenkins-service
namespace: jenkins
spec:
type: NodePort
selector:
app: jenkins
ports:
- port: 8080 (port on the service)
targetPort: 8080 (port on the pod)
nodePort: 30008 (port on the node)
Create a deployment with the given parameters
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: jenkins-deployment
namespace: jenkins
labels:
app: jenkins
spec:
replicas: 1
selector:
matchLabels:
app: jenkins
template:
metadata:
labels:
app: jenkins
spec:
containers:
- name: jenkins-container
image: jenkins/jenkins
ports:
- containerPort: 8080
Check to make sure that the deployment and services are running
kubectl get deployment
kubectl get service
Please, note that the NodePort is what will expose Jenkins on all kubernetes node IPs on port 30008