k8s中将Jenkins安装到master节点上的yaml

本文涉及的产品
传统型负载均衡 CLB,每月750个小时 15LCU
应用型负载均衡 ALB,每月750个小时 15LCU
容器服务 Serverless 版 ACK Serverless,317元额度 多规格
简介: Node将 pod 指定到特定的 node上有几种方式,使用label是个很好的方法,在执行前需要给每个node打个标签命令如下$ kubectl label node master nodename=master这句命令的意思是给master节点上打上 nodename=master 的标...

Node

将 pod 指定到特定的 node上有几种方式,使用label是个很好的方法,在执行前需要给每个node打个标签命令如下

$ kubectl label node master nodename=master

这句命令的意思是给master节点上打上 nodename=master 的标签,如此可以为其他节点也打上各自的标签

yaml 配置

---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: traefik-ingress-controller
rules:
  - apiGroups:
      - ""
    resources:
      - services
      - endpoints
      - secrets
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - extensions
    resources:
      - ingresses
    verbs:
      - get
      - list
      - watch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: traefik-ingress-controller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: traefik-ingress-controller
subjects:
- kind: ServiceAccount
  name: traefik-ingress-controller
  namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: traefik-ingress-controller
  namespace: kube-system
---
kind: DaemonSet
apiVersion: extensions/v1beta1
metadata:
  name: traefik-ingress-controller
  namespace: kube-system
  labels:
    k8s-app: traefik-ingress-lb
spec:
  template:
    metadata:
      labels:
        k8s-app: traefik-ingress-lb
        name: traefik-ingress-lb
    spec:
      serviceAccountName: traefik-ingress-controller
      terminationGracePeriodSeconds: 60
      hostNetwork: true
      containers:
      - image: traefik
        name: traefik-ingress-lb
        ports:
        - name: http
          containerPort: 80
          hostPort: 80
        - name: admin
          containerPort: 8080
        securityContext:
          capabilities:
            drop:
            - ALL
            add:
            - NET_BIND_SERVICE
        args:
        - --api
        - --kubernetes
        - --logLevel=INFO
---
apiVersion: v1
kind: Service
metadata:
  name: traefik-web-ui
  namespace: kube-system
spec:
  selector:
    k8s-app: traefik-ingress-lb
  ports:
  - name: web
    port: 80
    targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: jenkins-deployment
  namespace: kube-system
  labels:
    app: jenkins
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jenkins
  template:
    metadata:
      labels:
        app: jenkins
    spec:
      terminationGracePeriodSeconds: 60
      containers:
      - name: jenkins
        image: jenkins/jenkins:lts
        imagePullPolicy: IfNotPresent
        env:
          - name: JENKINS_OPTS
            value: "--prefix=/jenkins"
        ports:
        - name: web
          containerPort: 8080
          protocol: TCP
        - name: agent
          containerPort: 50000
          protocol: TCP
        volumeMounts:
        - name: jenkins-home
          mountPath: /var/jenkins_home
      volumes:
      - name: jenkins-home
        hostPath:
          path: /root/jenkins-home
      nodeSelector:
        nodename: master
---
apiVersion: v1
kind: Service
metadata:
  name: jenkins-service
  namespace: kube-system
  labels:
    app: jenkins
spec:
  ports:
  - port: 8888
    targetPort: 8080
    name: web
  - port: 50000
    targetPort: 50000
    name: agent
  selector:
    app: jenkins
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: traefik-web-ui
  namespace: kube-system
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.frontend.rule.type: PathPrefixStrip
spec:
  rules:
  - host: c4.k8s.com
    http:
      paths:
      - path: /ingress
        backend:
          serviceName: traefik-web-ui
          servicePort: web
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: jenkins-ingress
  namespace: kube-system
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.ingress.kubernetes.io/app-root: /jenkins
    traefik.ingress.kubernetes.io/rule-type: PathPrefix
    traefik.frontend.passHostHeader: "true"
spec:
  rules:
  - host: c4.k8s.com
    http:
      paths:
      - path: /jenkins
        backend:
          serviceName: jenkins-service
          servicePort: web
相关实践学习
通过Ingress进行灰度发布
本场景您将运行一个简单的应用,部署一个新的应用用于新的发布,并通过Ingress能力实现灰度发布。
容器应用与集群管理
欢迎来到《容器应用与集群管理》课程,本课程是“云原生容器Clouder认证“系列中的第二阶段。课程将向您介绍与容器集群相关的概念和技术,这些概念和技术可以帮助您了解阿里云容器服务ACK/ACK Serverless的使用。同时,本课程也会向您介绍可以采取的工具、方法和可操作步骤,以帮助您了解如何基于容器服务ACK Serverless构建和管理企业级应用。 学习完本课程后,您将能够: 掌握容器集群、容器编排的基本概念 掌握Kubernetes的基础概念及核心思想 掌握阿里云容器服务ACK/ACK Serverless概念及使用方法 基于容器服务ACK Serverless搭建和管理企业级网站应用
目录
相关文章
|
3天前
|
Kubernetes 应用服务中间件 nginx
Kubernetes上安装Metallb和Ingress并部署应用程序
Kubernetes上安装Metallb和Ingress并部署nginx应用程序,使用LoadBalancer类型的KubernetesService
27 3
|
17天前
|
Kubernetes 数据库 容器
k8s安装seata单机版
k8s安装seata单机版
|
17天前
|
消息中间件 Kubernetes 容器
k8s安装rabbbitmq
k8s安装rabbbitmq
|
17天前
|
Kubernetes NoSQL MongoDB
k8s安装YAPI
k8s安装YAPI
|
17天前
|
Kubernetes 关系型数据库 MySQL
k8s安装并迁移jumpserver
k8s安装并迁移jumpserver
|
23天前
|
Kubernetes jenkins 持续交付
在K8S中,Jenkins如何集成K8S集群?
在K8S中,Jenkins如何集成K8S集群?
|
27天前
|
存储 Kubernetes 负载均衡
在k8S中,Master节点高可用是如何做的?
在k8S中,Master节点高可用是如何做的?
|
1月前
|
存储 Kubernetes 容器
Kubernetes(K8S) kubesphere 安装
Kubernetes(K8S) kubesphere 安装
50 4
|
17天前
|
Kubernetes jenkins 持续交付
jenkins学习笔记之二十一:k8s部署jenkins及动态slave
jenkins学习笔记之二十一:k8s部署jenkins及动态slave
|
17天前
|
jenkins Java 持续交付
jenkins学习笔记之十九:Docker安装jenkins master及动、静态配置slave
jenkins学习笔记之十九:Docker安装jenkins master及动、静态配置slave