pipline脚本k8s版
def label = "jnlp-slave" podTemplate(label: label, cloud: 'kubernetes',containers: [ containerTemplate(name: 'jnlp-slave', image: 'jenkinsci/jnlp-slave:v1') ], volumes: [hostPathVolume(mounntPath:'/opt/maven/repository',hostPath:'/ceph/maven/repository'), hostPathVolume(mounntPath:'/usr/bin/docker',hostPath:'/usr/bin/docker'), hostPathVolume(mounntPath:'/var/run/docker.sock',hostPath:'/var/run/docker.sock')]) { node(label) { stage('Get a Maven project') { container(label) { stage('wait for exec check'){ sh 'sleep 10' } stage('deploy'){ echo 'deploy' sh ''' cat >deploy.yaml<<EOF apiVersion: extensions/v1beta1 kind: Deployment metadata: name: http-test-dm2 spec: replicas: 1 template: metadata: labels: name: http-test-dm2 spec: containers: - name: http-test-con image: nginx:alpine imagePullPolicy: Never ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: http-nginx-ser spec: type: NodePort ports: - port: 80 nodePort: 31000 targetPort: 80 selector: name: http-test-dm2 --- apiVersion: extensions/v1beta1 kind: Ingress metadata: name: grafana spec: rules: - host: www.nginx2.com http: paths: - path: / backend: serviceName: http-nginx-ser servicePort: 80 EOF ''' } stage('deploy to k8s'){ sh 'sleep 5' kubernetesDeploy configs: '', kubeConfig: [path: ''], kubeconfigId: '', secretName: '', ssh: [sshCredentialsId: '*', sshServer: ''], textCredentials: [certificateAuthorityData: '', clientCertificateData: '', clientKeyData: '', serverUrl: 'https://'] } } } } }