Giter VIP home page Giter VIP logo

installating_helm_jenkins's Introduction

Create Namespace

kubectl create ns jenkins

Create PVC

kubectl create -f jenkins-pvc.yaml

Deploy Helm Chart

helm install --name jenkins --namespace jenkins \
-f values.yaml \
--set Master.AdminPassword=jenkins,Master.Cpu="1",Master.Memory="1Gi",Master.HostName="jenkins.example.com",Agent.Cpu="1",Agent.Memory="1Gi",Persistence.Enabled=true,Persistence.ExistingClaim="jenkins-pvc" \
stable/jenkins

Create Jenkins Pipeline Job

  1. Cofigure Parameter
GIT_URL=https://github.com/YunSangJun/jenkins-test.git
GIT_BRANCH=master
DOCKER_REGISTRY=DOCKER_REGISTRY_URL:DOCKER_REGISTRY_PORT
DOCKER_REGISTRY_NAMESPACE=prod
DOCKER_ID=admin
DOCKER_PW=admin
DOCKER_IMAGE_NAME=IMAGE_NAME
K8S_CONF_PATH=./k8s/prd
DOCKER_IMAGE_VERSION=1.0
  1. Make Pipeline Script
podTemplate(label: 'jenkins-release-sj-jenkins-slave', containers: [
    containerTemplate(name: 'docker', image: 'docker', ttyEnabled: true, command: 'cat'),
    containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.0', command: 'cat', ttyEnabled: true)
  ],
  volumes: [
    hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
    persistentVolumeClaim(mountPath: '/home/jenkins/.m2', claimName: 'jenkins-pvc')
  ]) {
    node('jenkins-release-sj-jenkins-slave') {
        stage('Build') {
          git branch: env.GIT_BRANCH, url: env.GIT_URL
          sh './mvnw clean install'
        }
 
        stage('Image build') {
          container('docker') {
            sh 'docker build  . -t ' + env.DOCKER_REGISTRY+"/"+env.DOCKER_REGISTRY_NAMESPACE+"/"+env.DOCKER_IMAGE_NAME+":"+env.DOCKER_IMAGE_VERSION
            sh 'docker login ' + env.DOCKER_REGISTRY + ' -u ' + env.DOCKER_ID + ' -p ' + env.DOCKER_PW
            sh 'docker push ' + env.DOCKER_REGISTRY+"/"+env.DOCKER_REGISTRY_NAMESPACE+"/"+env.DOCKER_IMAGE_NAME+":"+env.DOCKER_IMAGE_VERSION
          }
        }
         
        stage('Deploy') {
            container('kubectl') {
                sh "kubectl apply -n " + env.DOCKER_REGISTRY_NAMESPACE + " -f " + env.K8S_CONF_PATH
            }
        }
  }
}

Configuration Jenkins System Properties

# of executors : 10

Additional Clusterrolebinding

To enable Jenkins to access all Namespaces, run the following command.

kubectl create -f cluster-role-binding.yaml

installating_helm_jenkins's People

Contributors

yunsangjun avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.