• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

eldada/jenkins-in-kubernetes: A Jenkins Docker image and helm chart for running ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

eldada/jenkins-in-kubernetes

开源软件地址(OpenSource Url):

https://github.com/eldada/jenkins-in-kubernetes

开源编程语言(OpenSource Language):

Dockerfile 43.0%

开源软件介绍(OpenSource Introduction):

Jenkins in Kubernetes

This repository has a Dockerfile and a helm chart for setting up a simple Jenkins master for running in Kubernetes.

This Jenkins has the required tools to work in and with Kubernetes

  • Jenkins application with pre-loaded plugins (see plugins.txt)
  • Skipped setup wizard
    • You can control admin user and password with --set adminUser=${USER},adminPassword=${PASSWORD}
    • You can add and remove plugins by editing the plugins.txt file
  • Docker for managing a Docker CI lifecycle
  • kubectl command line client for working with the Kubernetes API
  • helm for managing your helm charts CI/CD lifecycle

IMPORTANT: This example is for demo and testing. It should not be used a production environment!

Get the example Docker image

You can pull an already built version of this Jenkins image from bintray.com.

# Pull the image
docker pull eldada-docker-examples.bintray.io/jenkins:lts-k8s-20190827

Build the Jenkins Docker image

You can build the image yourself

export DOCKER_REG=SET_YOUR_DOCKER_REGISTRY_HERE

# Build the image
docker build -t ${DOCKER_REG}/jenkins:lts-k8s .

# Push the image
docker push ${DOCKER_REG}/jenkins:lts-k8s

Test your image

You can run your container locally, if you have Docker installed

  • Using the pre-built image
# Run the container you built before
docker run -d --name jenkins -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock eldada-docker-examples.bintray.io/jenkins:lts-k8s-20190827
  • Using your built image
# Run the container you built before
docker run -d --name jenkins -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock ${DOCKER_REG}/jenkins:lts-k8s

Deploy Jenkins helm chart to Kubernetes

If you are using the pre-built image eldada-docker-examples.bintray.io/jenkins:lts-k8s, you can install the helm chart with

# Init helm and tiller on your cluster
helm init

# Deploy the Jenkins helm chart
# (same command for install and upgrade)
helm upgrade --install jenkins ./helm/jenkins-k8s

NOTE: This helm chart deploys a pod with two containers. One for the Docker daemon and another for Jenkins. This is based on the suggestion in https://applatix.com/case-docker-docker-kubernetes-part-2/

If you are building your own version of Jenkins, you need your Kubernetes cluster to be able to pull the Docker image. You have to create a Docker registry secret and reference to it in your helm install command.

# Create a Docker registry secret
export DOCKER_REG=SET_YOUR_DOCKER_REGISTRY_HERE
export DOCKER_USR=SET_YOUR_DOCKER_USERNAME_HERE
export DOCKER_PWD=SET_YOUR_DOCKER_PASSWORD_HERE
export DOCKER_EML=SET_YOUR_DOCKER_EMAIL_HERE

kubectl create secret docker-registry docker-reg-secret \
        --docker-server=${DOCKER_REG} \
        --docker-username=${DOCKER_USR} \
        --docker-password=${DOCKER_PWD} \
        --docker-email=${DOCKER_EML}


# Deploy the Jenkins helm chart
# (same command for install and upgrade)
helm upgrade --install jenkins \
        --set imagePullSecrets=docker-reg-secret \
        --set image.repository=${DOCKER_REG}/jenkins \
        --set image.tag='lts-k8s' \
        ./helm/jenkins-k8s

Data persistence

By default, in Kubernetes, the Jenkins deployment uses a persistent volume claim that is mounted to /var/jenkins_home. This assures your data is saved across crashes, restarts and upgrades.

Vagrant

You can test your Docker image using Vagrant. The enclosed Vagrantfile will provision an Ubuntu VM with Docker.

  • Spin up the Vagrant VM then build and run the Docker image
# Spin up the Vagrant VM
vagrant up

# SSH into the VM
vagrant ssh

# Go to the mounted sources repository
cd /opt/provisioning

# Build and run your Jenkins container as shown above



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap