Skip to content

Instantly share code, notes, and snippets.

@carlossg
Last active June 12, 2017 17:50
Show Gist options
  • Save carlossg/e6d847e527ffc65af4a286681fc7c127 to your computer and use it in GitHub Desktop.
Save carlossg/e6d847e527ffc65af4a286681fc7c127 to your computer and use it in GitHub Desktop.
Kubernetes Hello World
/**
* This pipeline will deploy to Kubernetes
*/
library identifier: '[email protected]', retriever: modernSCM(
github(repoOwner: 'fabric8io', repository: 'fabric8-pipeline-library')
)
podTemplate(label: 'deploy', containers: [
containerTemplate(name: 'jnlp', image: 'jenkinsci/jnlp-slave:latest'),
]) {
def url = "https://gist.githubusercontent.com/carlossg/e6d847e527ffc65af4a286681fc7c127/raw/b446c13e78633d37a7b21cdf023ad584131b130b"
stage('deployment') {
node('deploy') {
sh "wget ${url}/kubernetes-hello-world-service.yaml"
sh "wget ${url}/kubernetes-hello-world-v1.yaml"
kubernetesApply(file: readFile('kubernetes-hello-world-service.yaml'), environment: 'kubernetes-plugin')
kubernetesApply(file: readFile('kubernetes-hello-world-v1.yaml'), environment: 'kubernetes-plugin')
}
}
stage('upgrade') {
timeout(time:1, unit:'DAYS') {
input message:'Approve upgrade?'
}
node('deploy') {
sh "wget ${url}/kubernetes-hello-world-v2.yaml"
kubernetesApply(file: readFile('kubernetes-hello-world-v2.yaml'), environment: 'kubernetes-plugin')
}
}
}
---
apiVersion: v1
kind: Service
metadata:
name: hello-world
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
selector:
name: hello-world
type: LoadBalancer
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: hello-world
labels:
name: hello-world
spec:
replicas: 10
template:
metadata:
labels:
name: hello-world
spec:
containers:
- name: hello-world
image: csanchez/hello-world:1.0
imagePullPolicy: Always
ports:
- containerPort: 8080
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: hello-world
labels:
name: hello-world
spec:
replicas: 10
template:
metadata:
labels:
name: hello-world
spec:
containers:
- name: hello-world
image: csanchez/hello-world:2.0
imagePullPolicy: Always
ports:
- containerPort: 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment