├── 03-jenkins-basics ├── README.md ├── jenkins │ ├── environments │ ├── kubernetes.list │ ├── hudson.model.UpdateCenter.xml │ ├── Dockerfile │ ├── sources.list │ └── Dockerfile-with-kubectl ├── docker-compose-jenkins-image.yml ├── docker-compose-with-kubectl.yaml └── docker-compose.yml ├── 07-jenkins-agents ├── ssh_keys │ ├── id_ed25529.pub │ ├── id_ecdsa.pub │ ├── id_ed25529 │ ├── id_rsa.pub │ ├── id_ecdsa │ └── id_rsa ├── conf │ ├── environments │ └── hudson.model.UpdateCenter.xml ├── README.md ├── docker-compose-inbound-agent.yml ├── docker-compose.yml └── docker-compose-ssh-agent.yml ├── 02-gitlab-ce-basics ├── postgresql │ └── environments ├── README.md ├── docker-compose.yaml └── gitlab │ └── environments ├── 06-jenkins-distributed-build ├── conf │ ├── environments │ └── hudson.model.UpdateCenter.xml ├── README.md └── docker-compose.yml ├── 08-jenkins-on-kubernetes ├── deploy │ ├── 01-namespace-jenkins.yaml │ ├── 02-pvc-jenkins.yaml │ ├── 06-pvc-maven-cache.yaml │ ├── 05-service-jenkins.yaml │ ├── 04-deploy-jenkins.yaml │ └── 03-rbac-jenkins.yaml ├── static-token-auth-example │ ├── auth │ │ └── tokens.csv │ ├── README.md │ └── kube-apiserver.yaml ├── ingress │ └── ingress-jenkins.yaml ├── coredns │ └── configmap-coredns.yaml └── README.md ├── 04-tomcat-with-manager ├── tomcat │ ├── Dockerfile │ ├── context.xml │ └── tomcat-users.xml ├── README.md ├── docker-compose.yaml └── docker-compose-multi-instances.yaml ├── 01-gitlab-ce-official ├── README.md ├── docker-compose-02.yaml └── docker-compose.yaml ├── 09-argocd-and-rollout ├── 02-metrics-ingress-nginx-controller │ ├── README.md │ └── service-ingress-nginx-controller.yaml ├── 01-ingress-argocd-and-rollouts │ ├── ingress-argocd.yaml │ └── ingress-argo-rollouts.yaml ├── rollout-demos │ ├── 06-argocd-application-and-rollouts.yaml │ ├── 04-rollouts-bluegreen-demo.yaml │ ├── 01-basic-rollouts-demo.yaml │ ├── 02-rollouts-with-ingress-nginx-traffic-shifting.yaml │ ├── 05-rollouts-bluegreen-with-analysis.yaml │ └── 03-rollouts-with-prometheus-analysis.yaml └── README.md ├── 05-sonarqube ├── README.md └── docker-compose.yaml ├── README.md └── LICENSE /03-jenkins-basics/README.md: -------------------------------------------------------------------------------- 1 | # Jenkins 2 | -------------------------------------------------------------------------------- /07-jenkins-agents/ssh_keys/id_ed25529.pub: -------------------------------------------------------------------------------- 1 | ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDdDrNkVRd10xiofQehVo2NbMRYv5QqYFxduvGs9pHsg root@linuxlab.magedu.com 2 | -------------------------------------------------------------------------------- /02-gitlab-ce-basics/postgresql/environments: -------------------------------------------------------------------------------- 1 | DB_USER=gitlab 2 | DB_PASS=MageEdu.C0m 3 | DB_NAME=gitlabhq_production 4 | DB_EXTENSION=pg_trgm,btree_gist 5 | -------------------------------------------------------------------------------- /02-gitlab-ce-basics/README.md: -------------------------------------------------------------------------------- 1 | # GitLab CE 2 | 3 | 该项目使用的是sameersbn的镜像文件,root用户的默认密码为“magedu.com”。它会运行三个服务: 4 | 5 | - redis 6 | - postgresql 7 | - gitlab-ce 8 | 9 | -------------------------------------------------------------------------------- /07-jenkins-agents/conf/environments: -------------------------------------------------------------------------------- 1 | JAVA_OPTS='-Dhudson.slaves.NodeProvisioner.initialDelay=0 -Duser.timezone=Asia/Shanghai -Djenkins.install.runSetupWizard=true' 2 | -------------------------------------------------------------------------------- /03-jenkins-basics/jenkins/environments: -------------------------------------------------------------------------------- 1 | JAVA_OPTS='-Dhudson.slaves.NodeProvisioner.initialDelay=0 -Duser.timezone=Asia/Shanghai -Djenkins.install.runSetupWizard=true' 2 | -------------------------------------------------------------------------------- /06-jenkins-distributed-build/conf/environments: -------------------------------------------------------------------------------- 1 | JAVA_OPTS='-Dhudson.slaves.NodeProvisioner.initialDelay=0 -Duser.timezone=Asia/Shanghai -Djenkins.install.runSetupWizard=true' 2 | -------------------------------------------------------------------------------- /08-jenkins-on-kubernetes/deploy/01-namespace-jenkins.yaml: -------------------------------------------------------------------------------- 1 | # Maintainer: MageEdu 2 | --- 3 | apiVersion: v1 4 | kind: Namespace 5 | metadata: 6 | name: jenkins 7 | -------------------------------------------------------------------------------- /03-jenkins-basics/jenkins/kubernetes.list: -------------------------------------------------------------------------------- 1 | deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://mirrors.cloud.tencent.com/kubernetes/apt/ kubernetes-xenial main 2 | -------------------------------------------------------------------------------- /04-tomcat-with-manager/tomcat/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM tomcat:jdk11 2 | RUN mv /usr/local/tomcat/webapps.dist/manager /usr/local/tomcat/webapps/ 3 | ADD ./context.xml /usr/local/tomcat/webapps/manager/META-INF/context.xml 4 | -------------------------------------------------------------------------------- /08-jenkins-on-kubernetes/static-token-auth-example/auth/tokens.csv: -------------------------------------------------------------------------------- 1 | 83d07d.d1d200dd0c85c694,tom,1001,"kube-users" 2 | 7dbe3f.03d7e8f69d576210,jerry,1002,"kube-admins" 3 | 07c31c.17bddf45d355d902,mageedu,1003,"kube-admins" 4 | -------------------------------------------------------------------------------- /06-jenkins-distributed-build/README.md: -------------------------------------------------------------------------------- 1 | # 基于Docker的Jenkins分布式构建环境 2 | 3 | 本示例会创建三个Jenkins实例,一个作为Jenkins Controller,另外两个作为Jenkins Agent。 4 | 5 | 端口的绑定需求: 6 | 7 | - Jenkins Master:8080 8 | - Agent01: 8081 9 | - Agent02: 8082 10 | 11 | -------------------------------------------------------------------------------- /01-gitlab-ce-official/README.md: -------------------------------------------------------------------------------- 1 | # GitLab CE 2 | 3 | 该项目中使用了GitLab官方制作的gitlab-ce镜像。 4 | 5 | ### Init Password 6 | 7 | 获取 root init password 8 | 9 | ```bash 10 | docker-compose exec gitlab grep 'Password:' /etc/gitlab/initial_root_password 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /07-jenkins-agents/conf/hudson.model.UpdateCenter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | default 5 | https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/current/update-center.json 6 | 7 | 8 | -------------------------------------------------------------------------------- /03-jenkins-basics/jenkins/hudson.model.UpdateCenter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | default 5 | https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/current/update-center.json 6 | 7 | 8 | -------------------------------------------------------------------------------- /06-jenkins-distributed-build/conf/hudson.model.UpdateCenter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | default 5 | https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/current/update-center.json 6 | 7 | 8 | -------------------------------------------------------------------------------- /04-tomcat-with-manager/README.md: -------------------------------------------------------------------------------- 1 | # Tomcat with Manager app 2 | 用于为Jenkins Pipeline提供运行servlet应用的tomcat服务,支持从Manager部署应用。 3 | 4 | - 容器监控的端口8080/TCP,映射的主机端口:8088/TCP; 5 | - Manager的访问URL为:http://HOST_IP:8088/manager 6 | - 用户名:tomcat,密码:magedu.com 7 | - 部署应用的默认路径为/usr/local/tomcat/webapps 8 | -------------------------------------------------------------------------------- /08-jenkins-on-kubernetes/static-token-auth-example/README.md: -------------------------------------------------------------------------------- 1 | # Kubernetes Static Token authn 2 | 3 | Copy token file 4 | 5 | ```bash 6 | cp -rp auth /etc/kubernetes/ 7 | ``` 8 | 9 | Copy apiserver manifest 10 | 11 | ```bash 12 | cp kube-apiserver.yaml /etc/kubernetes/manifests/ 13 | ``` 14 | -------------------------------------------------------------------------------- /07-jenkins-agents/ssh_keys/id_ecdsa.pub: -------------------------------------------------------------------------------- 1 | ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAGpLbgmWhWcZBYmRvLFLwTn13pBL/g56goWQVtQPJ28A4B5N2VoMSpy/PUFiPJ+OMRfe4ZqsWHRlRiYwbeI/8WEDwD691cG1RK99yj1LwOpgEP+HUy7TcTnkJSvrf91nUAsQXa8GaEhZpjDWMeEF3hSKEke/iU/hBmVmgY/ANFK3pV9Ng== root@linuxlab.magedu.com 2 | -------------------------------------------------------------------------------- /08-jenkins-on-kubernetes/deploy/02-pvc-jenkins.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: PersistentVolumeClaim 4 | metadata: 5 | name: jenkins-pvc 6 | namespace: jenkins 7 | spec: 8 | accessModes: 9 | - ReadWriteMany 10 | resources: 11 | requests: 12 | storage: 10Gi 13 | storageClassName: nfs-csi 14 | -------------------------------------------------------------------------------- /08-jenkins-on-kubernetes/deploy/06-pvc-maven-cache.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: PersistentVolumeClaim 4 | metadata: 5 | name: pvc-maven-cache 6 | namespace: jenkins 7 | spec: 8 | accessModes: 9 | - ReadWriteMany 10 | resources: 11 | requests: 12 | storage: 10Gi 13 | storageClassName: nfs-csi 14 | -------------------------------------------------------------------------------- /09-argocd-and-rollout/02-metrics-ingress-nginx-controller/README.md: -------------------------------------------------------------------------------- 1 | # 开启Ingress Nginx上的指标抓取 2 | 3 | Ingress Nginx用于暴露指标的端口为10254,因此,我们需要在其服务上通过Prometheus专用的Annotations进行标记。这些功能默认并未开启。 4 | 5 | ```yaml 6 | 7 | annotations: 8 | prometheus.io/scrape: "true" 9 | prometheus.io/port: "10254" 10 | ``` 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /03-jenkins-basics/jenkins/Dockerfile: -------------------------------------------------------------------------------- 1 | # Author: MageEdu 2 | # Site: http://www.magedu.com 3 | FROM jenkins/jenkins:jdk17 4 | ADD ./sources.list /etc/apt/sources.list 5 | USER root 6 | RUN apt-get update && \ 7 | apt-get -y install maven python3 docker.io golang gradle && \ 8 | # npm, php and ruby not installed 9 | apt-get clean 10 | -------------------------------------------------------------------------------- /07-jenkins-agents/ssh_keys/id_ed25529: -------------------------------------------------------------------------------- 1 | -----BEGIN OPENSSH PRIVATE KEY----- 2 | b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW 3 | QyNTUxOQAAACA3Q6zZFUXddMYqH0HoVaNjWzEWL+UKmBcXbrxrPaR7IAAAAKBCXr4GQl6+ 4 | BgAAAAtzc2gtZWQyNTUxOQAAACA3Q6zZFUXddMYqH0HoVaNjWzEWL+UKmBcXbrxrPaR7IA 5 | AAAEBlXKLVTI4R4Ag6dUVzpGtGJuWJ9tjy+C07yN37Ro8LEjdDrNkVRd10xiofQehVo2Nb 6 | MRYv5QqYFxduvGs9pHsgAAAAGHJvb3RAbGludXhsYWIubWFnZWR1LmNvbQECAwQF 7 | -----END OPENSSH PRIVATE KEY----- 8 | -------------------------------------------------------------------------------- /07-jenkins-agents/ssh_keys/id_rsa.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDImM93HAyMF5eJ8QsyaMkiON0h8T0hLXfohCm734Gd6b/9D/Nx5poaUvrfJgvnky3LdogzXwLUmdVcy588iTCt1u0gTIJ67YbSDUtdZHn6I2UMAvVmt6x7t+ZjTS/d1CJEX/mWOISIgDzxBQz1a9HstkfIH4MQCjdxaOmAFR65H8woNJ+QBFcBf60vRN9bXtfQDg2U7pFHdcNCjUs0HhnPsx6QtLXPErAndVFULjLPJLzD8zO+vCyqJbSFlbyD298lK7QmGd6DbYuHHZjzArRZ9rrHruFXW8P7weP+jIAkrmm72vx0WsvTf9T/Vzk4Bd9lHM8f4gu4/LheHwvhMMUk9ergqY06zty8yJC70SHw1ZJ2BzuKpgbhPugPRzpbzRhB2F4KkrGgRs91s/M/jCs4NNC7ACk+viKx0LFrydWsCy37uQRnUNFSv3dxgxwL4IIpefyZmfETGGpIgtCXbL9zPetH8OUKXf+cu3cWYeHbQfiiNy/FayGXN+peGVFhLWc= jenkins@jenkins.magedu.com 2 | -------------------------------------------------------------------------------- /08-jenkins-on-kubernetes/deploy/05-service-jenkins.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | name: jenkins 6 | namespace: jenkins 7 | labels: 8 | app: jenkins 9 | spec: 10 | selector: 11 | app: jenkins 12 | type: NodePort 13 | ports: 14 | - name: http 15 | port: 8080 16 | targetPort: 8080 17 | --- 18 | apiVersion: v1 19 | kind: Service 20 | metadata: 21 | name: jenkins-jnlp 22 | namespace: jenkins 23 | labels: 24 | app: jenkins 25 | spec: 26 | selector: 27 | app: jenkins 28 | ports: 29 | - name: agent 30 | port: 50000 31 | targetPort: 50000 32 | -------------------------------------------------------------------------------- /03-jenkins-basics/jenkins/sources.list: -------------------------------------------------------------------------------- 1 | deb https://repo.huaweicloud.com/debian/ bullseye main non-free contrib 2 | deb-src https://repo.huaweicloud.com/debian/ bullseye main non-free contrib 3 | deb https://repo.huaweicloud.com/debian-security/ bullseye-security main 4 | deb-src https://repo.huaweicloud.com/debian-security/ bullseye-security main 5 | deb https://repo.huaweicloud.com/debian/ bullseye-updates main non-free contrib 6 | deb-src https://repo.huaweicloud.com/debian/ bullseye-updates main non-free contrib 7 | deb https://repo.huaweicloud.com/debian/ bullseye-backports main non-free contrib 8 | deb-src https://repo.huaweicloud.com/debian/ bullseye-backports main non-free contrib 9 | -------------------------------------------------------------------------------- /03-jenkins-basics/jenkins/Dockerfile-with-kubectl: -------------------------------------------------------------------------------- 1 | # Author: MageEdu 2 | # Site: http://www.magedu.com 3 | FROM jenkins/jenkins:jdk17 4 | 5 | ADD ./sources.list /etc/apt/sources.list 6 | 7 | USER root 8 | 9 | RUN apt-get update && \ 10 | apt-get install -y apt-transport-https ca-certificates curl && \ 11 | curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://repo.huaweicloud.com/kubernetes/apt/doc/apt-key.gpg 12 | 13 | ADD ./kubernetes.list /etc/apt/sources.list.d/kubernetes.list 14 | 15 | RUN apt-get update && \ 16 | apt-get -y install maven python3 docker.io golang gradle kubectl && \ 17 | apt-get clean 18 | # npm, php and ruby not installed 19 | -------------------------------------------------------------------------------- /09-argocd-and-rollout/01-ingress-argocd-and-rollouts/ingress-argocd.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | name: argocd-server-ingress 5 | namespace: argocd 6 | annotations: 7 | nginx.ingress.kubernetes.io/force-ssl-redirect: "true" 8 | nginx.ingress.kubernetes.io/ssl-passthrough: "true" 9 | nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" 10 | spec: 11 | ingressClassName: 'nginx' 12 | rules: 13 | - host: argocd.magedu.com 14 | http: 15 | paths: 16 | - path: / 17 | pathType: Prefix 18 | backend: 19 | service: 20 | name: argocd-server 21 | port: 22 | name: https 23 | -------------------------------------------------------------------------------- /08-jenkins-on-kubernetes/ingress/ingress-jenkins.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | name: jenkins 5 | namespace: jenkins 6 | spec: 7 | ingressClassName: nginx 8 | rules: 9 | - host: cicd.magedu.com 10 | http: 11 | paths: 12 | - backend: 13 | service: 14 | name: jenkins 15 | port: 16 | number: 8080 17 | path: / 18 | pathType: Prefix 19 | - host: jenkins.magedu.com 20 | http: 21 | paths: 22 | - backend: 23 | service: 24 | name: jenkins 25 | port: 26 | number: 8080 27 | path: / 28 | pathType: Prefix 29 | -------------------------------------------------------------------------------- /09-argocd-and-rollout/01-ingress-argocd-and-rollouts/ingress-argo-rollouts.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | name: argo-rollouts 5 | namespace: argo-rollouts 6 | spec: 7 | ingressClassName: nginx 8 | rules: 9 | - host: rollouts.magedu.com 10 | http: 11 | paths: 12 | - backend: 13 | service: 14 | name: argo-rollouts-dashboard 15 | port: 16 | number: 3100 17 | path: / 18 | pathType: Prefix 19 | - host: rollout.magedu.com 20 | http: 21 | paths: 22 | - backend: 23 | service: 24 | name: argo-rollouts-dashboard 25 | port: 26 | number: 3100 27 | path: / 28 | pathType: Prefix 29 | -------------------------------------------------------------------------------- /07-jenkins-agents/ssh_keys/id_ecdsa: -------------------------------------------------------------------------------- 1 | -----BEGIN OPENSSH PRIVATE KEY----- 2 | b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAArAAAABNlY2RzYS 3 | 1zaGEyLW5pc3RwNTIxAAAACG5pc3RwNTIxAAAAhQQBqS24JloVnGQWJkbyxS8E59d6QS/4 4 | OeoKFkFbUDydvAOAeTdlaDEqcvz1BYjyfjjEX3uGarFh0ZUYmMG3iP/FhA8A+vdXBtUSvf 5 | co9S8DqYBD/h1Mu03E55CUr63/dZ1ALEF2vBmhIWaYw1jHhBd4UihJHv4lP4QZlZoGPwDR 6 | St6VfTYAAAEYzpAj6s6QI+oAAAATZWNkc2Etc2hhMi1uaXN0cDUyMQAAAAhuaXN0cDUyMQ 7 | AAAIUEAaktuCZaFZxkFiZG8sUvBOfXekEv+DnqChZBW1A8nbwDgHk3ZWgxKnL89QWI8n44 8 | xF97hmqxYdGVGJjBt4j/xYQPAPr3VwbVEr33KPUvA6mAQ/4dTLtNxOeQlK+t/3WdQCxBdr 9 | wZoSFmmMNYx4QXeFIoSR7+JT+EGZWaBj8A0UrelX02AAAAQgDjimtCwYR4AEbGuKFuoGOu 10 | 4RcEOR8Rr4eCWr/5IGnE9NFpM3KxQCzEuK6C5bEJ70hGt01SqRjVei1SG2duwtWGOAAAAB 11 | hyb290QGxpbnV4bGFiLm1hZ2VkdS5jb20BAg== 12 | -----END OPENSSH PRIVATE KEY----- 13 | -------------------------------------------------------------------------------- /05-sonarqube/README.md: -------------------------------------------------------------------------------- 1 | # SonarQube 2 | 3 | The following requirements and recommendations apply when running SonarQube in Docker in production. 4 | 5 | ### Set vm.max_map_count to at least 262144 6 | The vm.max_map_count kernel setting must be set to at least 262144 for production use. 7 | 8 | How you set vm.max_map_count depends on your platform. 9 | 10 | #### Linux 11 | 12 | To view the current value for the vm.max_map_count setting, run: 13 | 14 | ```bash 15 | grep vm.max_map_count /etc/sysctl.conf 16 | vm.max_map_count=262144 17 | ``` 18 | 19 | To apply the setting on a live system, run: 20 | 21 | ```bash 22 | sysctl -w vm.max_map_count=262144 23 | ``` 24 | 25 | To permanently change the value for the vm.max_map_count setting, update the value in /etc/sysctl.conf. 26 | 27 | ### 启动SonarQube Server 28 | 29 | 运行docker-compose up命令,即可完成环境初始化和启动。 30 | -------------------------------------------------------------------------------- /04-tomcat-with-manager/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | # Author: MageEdu 2 | # Site: http://www.magedu.com 3 | version: '3.6' 4 | 5 | volumes: 6 | tomcat_apps: {} 7 | 8 | networks: 9 | tomcat_net: 10 | driver: bridge 11 | ipam: 12 | config: 13 | - subnet: 172.31.4.0/24 14 | 15 | services: 16 | tomcat: 17 | #image: tomcat:jdk11 18 | build: 19 | context: tomcat 20 | dockerfile: Dockerfile 21 | hostname: tomcat.magedu.com 22 | container_name: tomcat 23 | ports: 24 | - 8088:8080 25 | volumes: 26 | - tomcat_apps:/usr/local/tomcat/webapps 27 | - ./tomcat/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml 28 | networks: 29 | tomcat_net: 30 | ipv4_address: 172.31.4.2 31 | aliases: 32 | - tomcat 33 | - apps 34 | environment: 35 | TZ: Asia/Shanghai 36 | restart: always 37 | -------------------------------------------------------------------------------- /08-jenkins-on-kubernetes/coredns/configmap-coredns.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | data: 3 | Corefile: | 4 | .:53 { 5 | errors 6 | health { 7 | lameduck 5s 8 | } 9 | ready 10 | hosts { 11 | 172.29.7.7 jenkins.magedu.com 12 | 172.29.7.8 sonar.magedu.com 13 | 172.29.7.6 gitlab.magedu.com 14 | 172.29.9.200 hub.magedu.com 15 | fallthrough 16 | } 17 | kubernetes cluster.local in-addr.arpa ip6.arpa { 18 | pods insecure 19 | fallthrough in-addr.arpa ip6.arpa 20 | ttl 30 21 | } 22 | prometheus :9153 23 | forward . /etc/resolv.conf { 24 | max_concurrent 1000 25 | } 26 | cache 30 27 | loop 28 | reload 29 | loadbalance 30 | } 31 | kind: ConfigMap 32 | metadata: 33 | name: coredns 34 | namespace: kube-system 35 | -------------------------------------------------------------------------------- /03-jenkins-basics/docker-compose-jenkins-image.yml: -------------------------------------------------------------------------------- 1 | # Author: MageEdu 2 | # Site: http://www.magedu.com 3 | version: '3.6' 4 | 5 | volumes: 6 | jenkins_data: {} 7 | maven_cache: {} 8 | 9 | networks: 10 | jenkins_net: 11 | driver: bridge 12 | ipam: 13 | config: 14 | - subnet: 172.31.2.0/24 15 | 16 | services: 17 | jenkins: 18 | #build: 19 | # context: jenkins 20 | # dockerfile: Dockerfile 21 | image: jenkins/jenkins:jdk17 22 | hostname: jenkins.magedu.com 23 | user: root 24 | env_file: 25 | - jenkins/environments 26 | volumes: 27 | - jenkins_data:/var/jenkins_home:Z 28 | - /var/run/docker.sock:/var/run/docker.sock:ro 29 | - maven_cache:/root/.m2 30 | ports: 31 | - 8080:8080 32 | - 50000:50000 33 | networks: 34 | jenkins_net: 35 | ipv4_address: 172.31.2.2 36 | aliases: 37 | - jenkins_masters 38 | - masters 39 | - jenkins_master01 40 | - master01 41 | restart: always 42 | -------------------------------------------------------------------------------- /09-argocd-and-rollout/rollout-demos/06-argocd-application-and-rollouts.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: Application 3 | metadata: 4 | name: spring-boot-helloworld 5 | namespace: argocd 6 | spec: 7 | project: default 8 | source: 9 | repoURL: https://gitee.com/mageedu/spring-boot-helloworld.git 10 | targetRevision: HEAD 11 | path: rollouts 12 | destination: 13 | server: https://kubernetes.default.svc 14 | # This sample must run in demo namespace. 15 | namespace: demo 16 | syncPolicy: 17 | automated: 18 | prune: true 19 | selfHeal: true 20 | allowEmpty: false 21 | syncOptions: 22 | - Validate=false 23 | - CreateNamespace=true 24 | - PrunePropagationPolicy=foreground 25 | - PruneLast=true 26 | - ApplyOutOfSyncOnly=true 27 | retry: 28 | limit: 5 29 | backoff: 30 | duration: 5s 31 | factor: 2 32 | maxDuration: 3m 33 | ignoreDifferences: 34 | - group: networking.k8s.io 35 | kind: Ingress 36 | jsonPointers: 37 | - /spec/http/0 38 | -------------------------------------------------------------------------------- /03-jenkins-basics/docker-compose-with-kubectl.yaml: -------------------------------------------------------------------------------- 1 | # Author: MageEdu 2 | # Site: http://www.magedu.com 3 | version: '3.6' 4 | 5 | volumes: 6 | jenkins_data: {} 7 | maven_cache: {} 8 | 9 | networks: 10 | jenkins_net: 11 | driver: bridge 12 | ipam: 13 | config: 14 | - subnet: 172.31.3.0/24 15 | 16 | services: 17 | jenkins: 18 | build: 19 | context: jenkins 20 | dockerfile: Dockerfile-with-kubectl 21 | hostname: jenkins.magedu.com 22 | user: root 23 | env_file: 24 | - jenkins/environments 25 | environment: 26 | TZ: Asia/Shanghai 27 | volumes: 28 | - jenkins_data:/var/jenkins_home:Z 29 | - /var/run/docker.sock:/var/run/docker.sock:ro 30 | - maven_cache:/root/.m2 31 | ports: 32 | - 8080:8080 33 | - 50000:50000 34 | networks: 35 | jenkins_net: 36 | ipv4_address: 172.31.3.2 37 | aliases: 38 | - jenkins_master 39 | - master 40 | - jenkins_master01 41 | - master01 42 | restart: always 43 | -------------------------------------------------------------------------------- /03-jenkins-basics/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Author: MageEdu 2 | # Site: http://www.magedu.com 3 | version: '3.6' 4 | 5 | volumes: 6 | jenkins_data: {} 7 | maven_cache: {} 8 | 9 | networks: 10 | jenkins_net: 11 | driver: bridge 12 | ipam: 13 | config: 14 | - subnet: 172.31.3.0/24 15 | 16 | services: 17 | jenkins: 18 | build: 19 | context: jenkins 20 | dockerfile: Dockerfile 21 | #image: jenkins/jenkins:jdk11 22 | hostname: jenkins.magedu.com 23 | user: root 24 | env_file: 25 | - jenkins/environments 26 | environment: 27 | TZ: Asia/Shanghai 28 | volumes: 29 | - jenkins_data:/var/jenkins_home:Z 30 | - /var/run/docker.sock:/var/run/docker.sock:ro 31 | - maven_cache:/root/.m2 32 | ports: 33 | - 8080:8080 34 | - 50000:50000 35 | networks: 36 | jenkins_net: 37 | ipv4_address: 172.31.3.2 38 | aliases: 39 | - jenkins_master 40 | - master 41 | - jenkins_master01 42 | - master01 43 | restart: always 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Learning-Jenkins-CICD 2 | 3 | 本项目是[马哥教育](http://www.magedu.com)的Jenkins实践专题课程的实践代码库。 4 | 5 | ## iKubernetes公众号 6 | 7 | ![ikubernetes公众号二维码](https://github.com/iKubernetes/Kubernetes_Advanced_Practical_2rd/raw/main/imgs/iKubernetes%E5%85%AC%E4%BC%97%E5%8F%B7%E4%BA%8C%E7%BB%B4%E7%A0%81.jpg) 8 | 9 | ## 《Kubernetes进阶实战第2版》 10 | 11 | - [淘宝直达](https://s.taobao.com/search?q=kubernetes%E8%BF%9B%E9%98%B6%E5%AE%9E%E6%88%98%E7%AC%AC2%E7%89%88&imgfile=&commend=all&ssid=s5-e&search_type=item&sourceId=tb.index&spm=a21bo.2017.201856-taobao-item.1&ie=utf8&initiative_id=tbindexz_20170306) 12 | - [京东商城直达](https://search.jd.com/Search?keyword=kubernetes%E8%BF%9B%E9%98%B6%E5%AE%9E%E6%88%98%E7%AC%AC2%E7%89%88&enc=utf-8&suggest=2.def.0.base&wq=kubernetes%E8%BF%9B%E9%98%B6%E5%AE%9E%E6%88%98&pvid=286ff777931e4075a762f321a0fb1139) 13 | - [当当直达](http://search.dangdang.com/?key=kubernetes%BD%F8%BD%D7%CA%B5%D5%BD%B5%DA%B6%FE%B0%E6&act=input) 14 | 15 | ![图书封面](https://github.com/iKubernetes/Kubernetes_Advanced_Practical_2rd/raw/main/imgs/book.jpg) 16 | 17 | ### 版权声明 18 | 本文档由[马哥教育](www.magedu.com)开发,允许自由转载,但必须保留马哥教育及相关的一切标识。另外,商用需要征得马哥教育的书面同意。 19 | -------------------------------------------------------------------------------- /01-gitlab-ce-official/docker-compose-02.yaml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | 3 | volumes: 4 | gitlab_data: {} 5 | gitlab_logs: {} 6 | gitlab_conf: {} 7 | 8 | networks: 9 | gitlab_net: 10 | driver: bridge 11 | ipam: 12 | config: 13 | - subnet: 172.31.0.0/24 14 | 15 | services: 16 | gitlab: 17 | image: gitlab/gitlab-ce:16.0.1-ce.0 18 | restart: always 19 | hostname: 'gitlab.example.com' 20 | environment: 21 | #GITLAB_HOME: /gitlab 22 | GITLAB_OMNIBUS_CONFIG: | 23 | external_url 'https://gitlab.magedu.com:8929' 24 | gitlab_rails['gitlab_shell_ssh_port'] = 22022 25 | # Add any other gitlab.rb configuration here, each on its own line 26 | ports: 27 | - '8929:8929' 28 | - '22022:22' 29 | volumes: 30 | - 'gitlab_conf:/etc/gitlab' 31 | - 'gitlab_logs:/var/log/gitlab' 32 | - 'gitlab_data:/var/opt/gitlab' 33 | #- '$GITLAB_HOME/config:/etc/gitlab' 34 | #- '$GITLAB_HOME/logs:/var/log/gitlab' 35 | #- '$GITLAB_HOME/data:/var/opt/gitlab' 36 | shm_size: '256m' 37 | networks: 38 | gitlab_net: 39 | ipv4_address: 172.31.0.2 40 | aliases: 41 | - codehub 42 | -------------------------------------------------------------------------------- /09-argocd-and-rollout/02-metrics-ingress-nginx-controller/service-ingress-nginx-controller.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | annotations: 5 | prometheus.io/scrape: "true" 6 | prometheus.io/port: "10254" 7 | labels: 8 | app.kubernetes.io/component: controller 9 | app.kubernetes.io/instance: ingress-nginx 10 | app.kubernetes.io/name: ingress-nginx 11 | app.kubernetes.io/part-of: ingress-nginx 12 | name: ingress-nginx-controller 13 | namespace: ingress-nginx 14 | spec: 15 | allocateLoadBalancerNodePorts: true 16 | #externalIPs: 17 | #- 172.29.9.200 18 | externalTrafficPolicy: Cluster 19 | internalTrafficPolicy: Cluster 20 | ipFamilies: 21 | - IPv4 22 | ipFamilyPolicy: SingleStack 23 | ports: 24 | - appProtocol: http 25 | name: http 26 | port: 80 27 | protocol: TCP 28 | targetPort: http 29 | - appProtocol: https 30 | name: https 31 | port: 443 32 | protocol: TCP 33 | targetPort: https 34 | selector: 35 | app.kubernetes.io/component: controller 36 | app.kubernetes.io/instance: ingress-nginx 37 | app.kubernetes.io/name: ingress-nginx 38 | sessionAffinity: None 39 | type: LoadBalancer 40 | -------------------------------------------------------------------------------- /01-gitlab-ce-official/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | # Author: MageEdu 2 | # Site: http://www.magedu.com 3 | version: '3.6' 4 | 5 | volumes: 6 | gitlab_data: {} 7 | gitlab_logs: {} 8 | gitlab_conf: {} 9 | 10 | networks: 11 | gitlab_net: 12 | driver: bridge 13 | ipam: 14 | config: 15 | - subnet: 172.31.0.0/24 16 | 17 | services: 18 | gitlab: 19 | image: gitlab/gitlab-ce:16.0.1-ce.0 20 | restart: always 21 | hostname: 'gitlab.example.com' 22 | environment: 23 | #GITLAB_HOME: /gitlab 24 | GITLAB_OMNIBUS_CONFIG: | 25 | #external_url 'https://code.magedu.com' 26 | gitlab_rails['gitlab_shell_ssh_port'] = 22022 27 | # Add any other gitlab.rb configuration here, each on its own line 28 | ports: 29 | - '80:80' 30 | #- '443:443' 31 | - '22022:22' 32 | volumes: 33 | - 'gitlab_conf:/etc/gitlab' 34 | - 'gitlab_logs:/var/log/gitlab' 35 | - 'gitlab_data:/var/opt/gitlab' 36 | #- '$GITLAB_HOME/config:/etc/gitlab' 37 | #- '$GITLAB_HOME/logs:/var/log/gitlab' 38 | #- '$GITLAB_HOME/data:/var/opt/gitlab' 39 | shm_size: '256m' 40 | networks: 41 | gitlab_net: 42 | ipv4_address: 172.31.0.2 43 | aliases: 44 | - codehub 45 | -------------------------------------------------------------------------------- /08-jenkins-on-kubernetes/deploy/04-deploy-jenkins.yaml: -------------------------------------------------------------------------------- 1 | # Author: MageEdu 2 | # Site: www.magedu.com 3 | --- 4 | apiVersion: apps/v1 5 | kind: Deployment 6 | metadata: 7 | name: jenkins 8 | namespace: jenkins 9 | spec: 10 | replicas: 1 11 | selector: 12 | matchLabels: 13 | app: jenkins 14 | template: 15 | metadata: 16 | labels: 17 | app: jenkins 18 | spec: 19 | serviceAccountName: jenkins-master 20 | volumes: 21 | - name: jenkins-store 22 | persistentVolumeClaim: 23 | claimName: jenkins-pvc 24 | containers: 25 | - name: jenkins 26 | image: jenkins/jenkins:jdk11 27 | volumeMounts: 28 | - name: jenkins-store 29 | mountPath: /var/jenkins_home/ 30 | imagePullPolicy: Always 31 | env: 32 | - name: JAVA_OPTS 33 | value: -XshowSettings:vm -Dhudson.slaves.NodeProvisioner.initialDelay=0 -Dhudson.slaves.NodeProvisioner.MARGIN=50 -Dhudson.slaves.NodeProvisioner.MARGIN0=0.85 -Duser.timezone=Asia/Shanghai -Djenkins.install.runSetupWizard=true 34 | ports: 35 | - containerPort: 8080 36 | name: web 37 | protocol: TCP 38 | - containerPort: 50000 39 | name: agent 40 | protocol: TCP 41 | -------------------------------------------------------------------------------- /05-sonarqube/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | # Author: MageEdu 2 | # Site: http://www.magedu.com 3 | version: "3.6" 4 | 5 | volumes: 6 | sonarqube: {} 7 | postgresql: {} 8 | 9 | networks: 10 | jenkins_net: 11 | driver: bridge 12 | ipam: 13 | config: 14 | - subnet: 172.31.5.0/24 15 | 16 | services: 17 | sonarqube: 18 | image: sonarqube:community 19 | hostname: sonar.magedu.com 20 | container_name: sonarqube 21 | depends_on: 22 | - db 23 | environment: 24 | SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar 25 | SONAR_JDBC_USERNAME: sonar 26 | SONAR_JDBC_PASSWORD: sonar 27 | volumes: 28 | - sonarqube:/opt/sonarqube 29 | ports: 30 | - "9000:9000" 31 | networks: 32 | jenkins_net: 33 | ipv4_address: 172.31.5.2 34 | aliases: 35 | - sonar 36 | - sonarqube 37 | - sonarqube.magedu.com 38 | restart: always 39 | 40 | db: 41 | image: postgres:12 42 | hostname: postgresql 43 | container_name: postgresql 44 | environment: 45 | POSTGRES_USER: sonar 46 | POSTGRES_PASSWORD: sonar 47 | POSTGRES_DB: sonar 48 | volumes: 49 | - postgresql:/var/lib/postgresql 50 | networks: 51 | jenkins_net: 52 | ipv4_address: 172.31.5.3 53 | restart: always 54 | -------------------------------------------------------------------------------- /07-jenkins-agents/README.md: -------------------------------------------------------------------------------- 1 | # 基于Docker的Jenkins分布式构建环境 2 | 3 | 本示例仓库用于为Jenkins Controller提供基于Docker容器的静态Agent。 4 | 5 | ### 基于docker容器的 jnlp Agent 6 | 7 | 使用方法: 8 | 9 | - 首先,在Jenkins上,开启允许jnlp agent接入:系统管理 --> 全局安全配置 10 | 11 | - 而后,在Jenkins Controller上创建两个固定的Agent,其标识分别为agent01.magedu.com和agent02.magedu.com,启动方式为“通过Java Web启动代理”; 12 | 13 | - 接着,在Jenkins Controller上获取这两个Agent的Secret,并更新到docker-compose-inbound-agent.yml文件中对应的agent之上; 14 | 15 | - 最后,运行如下命令,启用docker jnlp agent 16 | 17 | ```bash 18 | docker-compose -f docker-compose-inbound-agent.yml up -d 19 | ``` 20 | 21 | ### 基于docker容器的 ssh agent 22 | 23 | 使用方法: 24 | 25 | - 首先,使用ssh-keygen命令生成一对rsa格式的密钥; 26 | 27 | - 而后,将私钥创建为Jenkins Controller之上的"SSH Username with private key"类型的Credential,用户名为“jenkins”,私钥即为前一步中由命令生成的私钥; 28 | 29 | - 接着,将ssh-keygen命令生成的公钥信息更新到docker-compose-ssh-agent.yml文件中的各agent上的环境变量JENKINS_AGENT_SSH_PUBKEY的值;两个agent使用同一个公钥即可; 30 | 31 | - 再接着,在Jenkins Controller上添加两个固定的Agent,启动方式为“Lanch aget via SSH”,各agent的标识分别为ssh-agent01.magedu.com和ssh-agent02.magedu.com; 32 | 33 | - 最后,运行如下命令,启用docker jnlp agent 34 | 35 | ```bash 36 | docker-compose -f docker-compose-ssh-agent.yml up -d 37 | ``` 38 | 39 | ### 说明 40 | 41 | 基于Docker容器的静态Agent,其基础系统环境由相应的Docker Image生成,缺少很多工具程序。需要用到镜像中不具有的程序时,可以通过在Jenkins上设置全局工具程序,让Agent自动安装,也可自行基于基础镜像构建带有必要工具的镜像来。 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /08-jenkins-on-kubernetes/deploy/03-rbac-jenkins.yaml: -------------------------------------------------------------------------------- 1 | # Author: MageEdu 2 | # Site: www.magedu.com 3 | --- 4 | apiVersion: v1 5 | kind: ServiceAccount 6 | metadata: 7 | name: jenkins-master 8 | namespace: jenkins 9 | 10 | --- 11 | apiVersion: rbac.authorization.k8s.io/v1 12 | kind: ClusterRole 13 | metadata: 14 | name: jenkins-master 15 | rules: 16 | - apiGroups: ["extensions", "apps"] 17 | resources: ["deployments"] 18 | verbs: ["create", "delete", "get", "list", "watch", "patch", "update"] 19 | - apiGroups: [""] 20 | resources: ["services"] 21 | verbs: ["create", "delete", "get", "list", "watch", "patch", "update"] 22 | - apiGroups: [""] 23 | resources: ["pods"] 24 | verbs: ["create","delete","get","list","patch","update","watch"] 25 | - apiGroups: [""] 26 | resources: ["pods/exec"] 27 | verbs: ["create","delete","get","list","patch","update","watch"] 28 | - apiGroups: [""] 29 | resources: ["pods/log"] 30 | verbs: ["get","list","watch"] 31 | - apiGroups: [""] 32 | resources: ["secrets"] 33 | verbs: ["get"] 34 | 35 | --- 36 | apiVersion: rbac.authorization.k8s.io/v1 37 | kind: ClusterRoleBinding 38 | metadata: 39 | name: jenkins-master 40 | roleRef: 41 | kind: ClusterRole 42 | name: jenkins-master 43 | apiGroup: rbac.authorization.k8s.io 44 | subjects: 45 | - kind: ServiceAccount 46 | name: jenkins-master 47 | namespace: jenkins 48 | -------------------------------------------------------------------------------- /04-tomcat-with-manager/tomcat/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 21 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /02-gitlab-ce-basics/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | # Author: MageEdu 2 | # Site: http://www.magedu.com 3 | version: '3.6' 4 | 5 | volumes: 6 | redis_data: {} 7 | postgresql_data: {} 8 | gitlab_data: {} 9 | 10 | networks: 11 | gitlab_net: 12 | driver: bridge 13 | ipam: 14 | config: 15 | - subnet: 172.31.2.0/24 16 | 17 | services: 18 | 19 | redis: 20 | restart: always 21 | image: redis:6.2.6 22 | networks: 23 | gitlab_net: 24 | ipv4_address: 172.31.2.8 25 | aliases: 26 | - kvstor 27 | command: 28 | - --loglevel warning 29 | volumes: 30 | - redis_data:/data:Z 31 | 32 | postgresql: 33 | restart: always 34 | image: sameersbn/postgresql:12-20200524 35 | networks: 36 | gitlab_net: 37 | ipv4_address: 172.31.2.9 38 | aliases: 39 | - db 40 | - dbstor 41 | volumes: 42 | - postgresql_data:/var/lib/postgresql:Z 43 | env_file: 44 | - postgresql/environments 45 | 46 | gitlab: 47 | image: sameersbn/gitlab:16.0.1 48 | hostname: gitlab.magedu.com 49 | depends_on: 50 | - redis 51 | - postgresql 52 | networks: 53 | gitlab_net: 54 | ipv4_address: 172.31.2.2 55 | aliases: 56 | - gitlab 57 | - ci 58 | - codehub 59 | ports: 60 | - "80:80" 61 | - "10022:22" 62 | volumes: 63 | - gitlab_data:/home/git/data:Z 64 | healthcheck: 65 | test: ["CMD", "/usr/local/sbin/healthcheck"] 66 | interval: 2m 67 | timeout: 10s 68 | retries: 3 69 | start_period: 5m 70 | env_file: 71 | - gitlab/environments 72 | restart: always 73 | -------------------------------------------------------------------------------- /09-argocd-and-rollout/rollout-demos/04-rollouts-bluegreen-demo.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: Rollout 3 | metadata: 4 | name: rollout-helloworld-bluegreen 5 | spec: 6 | replicas: 3 7 | revisionHistoryLimit: 5 8 | selector: 9 | matchLabels: 10 | app: rollout-helloworld-bluegreen 11 | template: 12 | metadata: 13 | labels: 14 | app: rollout-helloworld-bluegreen 15 | spec: 16 | containers: 17 | - name: spring-boot-helloworld 18 | image: ikubernetes/spring-boot-helloworld:v0.9.2 19 | ports: 20 | - containerPort: 80 21 | strategy: 22 | blueGreen: 23 | activeService: spring-boot-helloworld 24 | previewService: spring-boot-helloworld-preview 25 | autoPromotionEnabled: false 26 | --- 27 | kind: Service 28 | apiVersion: v1 29 | metadata: 30 | name: spring-boot-helloworld 31 | spec: 32 | selector: 33 | app: rollout-helloworld-bluegreen 34 | ports: 35 | - protocol: TCP 36 | port: 80 37 | targetPort: 80 38 | 39 | --- 40 | kind: Service 41 | apiVersion: v1 42 | metadata: 43 | name: spring-boot-helloworld-preview 44 | spec: 45 | selector: 46 | app: rollout-helloworld-bluegreen 47 | ports: 48 | - protocol: TCP 49 | port: 80 50 | targetPort: 80 51 | --- 52 | apiVersion: networking.k8s.io/v1 53 | kind: Ingress 54 | metadata: 55 | name: spring-boot-helloworld 56 | spec: 57 | ingressClassName: "nginx" 58 | rules: 59 | - host: hello.magedu.com 60 | http: 61 | paths: 62 | - path: / 63 | pathType: Prefix 64 | backend: 65 | service: 66 | name: spring-boot-helloworld 67 | port: 68 | number: 80 69 | --- 70 | -------------------------------------------------------------------------------- /07-jenkins-agents/docker-compose-inbound-agent.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | 3 | volumes: 4 | agent01_data: {} 5 | agent02_data: {} 6 | 7 | networks: 8 | jenkins_net: 9 | driver: bridge 10 | ipam: 11 | config: 12 | - subnet: 172.31.9.0/24 13 | 14 | services: 15 | agent01: 16 | image: jenkins/inbound-agent:alpine-jdk11 17 | hostname: agent01.magedu.com 18 | user: root 19 | environment: 20 | TZ: Asia/Shanghai 21 | JENKINS_URL: http://jenkins.magedu.com:8080 22 | JENKINS_AGENT_NAME: agent01.magedu.com 23 | JENKINS_AGENT_WORKDIR: /home/jenkins/agent 24 | JENKINS_SECRET: a302b485b9e4f08b1f8998251656d143e9ecad6d705f00c36a8fb8d26b1ef7a3 25 | # SECRET is automatically generated by the master when adding agent01. 26 | volumes: 27 | - agent01_data:/appdata/jenkins/ 28 | networks: 29 | jenkins_net: 30 | ipv4_address: 172.31.9.11 31 | aliases: 32 | - slave01 33 | - agent01 34 | #extra_hosts: 35 | # - "jenkins.magedu.com:172.29.7.7" 36 | #restart: always 37 | 38 | agent02: 39 | image: jenkins/inbound-agent:alpine-jdk11 40 | hostname: agent02.magedu.com 41 | user: root 42 | environment: 43 | TZ: Asia/Shanghai 44 | JENKINS_URL: http://jenkins.magedu.com:8080 45 | JENKINS_AGENT_NAME: agent02.magedu.com 46 | JENKINS_AGENT_WORKDIR: /home/jenkins/agent 47 | JENKINS_SECRET: 38f226a11906cb319dc3f41e8a6bd1a7dd1f2f234eaf24189aa5a6502d1c49d6 48 | # SECRET is automatically generated by the master when adding agent02. 49 | volumes: 50 | - agent02_data:/appdata/jenkins/ 51 | networks: 52 | jenkins_net: 53 | ipv4_address: 172.31.9.12 54 | aliases: 55 | - slave02 56 | - agent02 57 | #extra_hosts: 58 | # - "jenkins.magedu.com:172.29.7.7" 59 | #restart: always 60 | -------------------------------------------------------------------------------- /07-jenkins-agents/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | 3 | volumes: 4 | agent01_data: {} 5 | slave02_data: {} 6 | 7 | networks: 8 | jenkins_net: 9 | driver: bridge 10 | ipam: 11 | config: 12 | - subnet: 172.31.9.0/24 13 | 14 | services: 15 | agent01: 16 | image: jenkins/inbound-agent:alpine-jdk11 17 | hostname: agent01.magedu.com 18 | user: root 19 | environment: 20 | TZ: Asia/Shanghai 21 | JENKINS_URL: http://jenkins.magedu.com:8080 22 | JENKINS_AGENT_NAME: agent01.magedu.com 23 | JENKINS_AGENT_WORKDIR: /appdata/jenkins/ 24 | JENKINS_SECRET: e91ea475faac4d734164802e7446c3c50bad9131d941d93e8c3cbe4ebf067251 25 | # SECRET is automatically generated by the master when adding agent01. 26 | volumes: 27 | - agent01_data:/appdata/jenkins/ 28 | networks: 29 | jenkins_net: 30 | ipv4_address: 172.31.9.11 31 | aliases: 32 | - slave01 33 | - agent01 34 | #extra_hosts: 35 | # - "jenkins.magedu.com:${JENKINS_HOST_IP}" 36 | #restart: always 37 | 38 | agent02: 39 | image: jenkins/inbound-agent:alpine-jdk11 40 | hostname: agent02.magedu.com 41 | user: root 42 | environment: 43 | TZ: Asia/Shanghai 44 | JENKINS_URL: http://jenkins.magedu.com:8080 45 | JENKINS_AGENT_NAME: agent02.magedu.com 46 | JENKINS_AGENT_WORKDIR: /appdata/jenkins/ 47 | JENKINS_SECRET: 87be0f8c1bea409acaef7c74d327fd61a133e075e93754b9f7b01b333f3ace15 48 | # SECRET is automatically generated by the master when adding agent02. 49 | volumes: 50 | - agent01_data:/appdata/jenkins/ 51 | networks: 52 | jenkins_net: 53 | ipv4_address: 172.31.9.12 54 | aliases: 55 | - slave02 56 | - agent02 57 | #extra_hosts: 58 | # - "jenkins.magedu.com:${JENKINS_HOST_IP}" 59 | #restart: always 60 | -------------------------------------------------------------------------------- /04-tomcat-with-manager/docker-compose-multi-instances.yaml: -------------------------------------------------------------------------------- 1 | # Author: MageEdu 2 | # Site: http://www.magedu.com 3 | version: '3.6' 4 | 5 | volumes: 6 | tomcat01_apps: {} 7 | tomcat02_apps: {} 8 | tomcat03_apps: {} 9 | 10 | networks: 11 | tomcat_net: 12 | driver: bridge 13 | ipam: 14 | config: 15 | - subnet: 172.31.4.0/24 16 | 17 | services: 18 | tomcat01: 19 | #image: tomcat:jdk11 20 | build: 21 | context: tomcat 22 | dockerfile: Dockerfile 23 | hostname: tomcat01.magedu.com 24 | ports: 25 | - 8088:8080 26 | volumes: 27 | - tomcat01_apps:/usr/local/tomcat/webapps 28 | - ./tomcat/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml 29 | networks: 30 | tomcat_net: 31 | ipv4_address: 172.31.4.11 32 | aliases: 33 | - tomcat01 34 | - tomcat 35 | environment: 36 | TZ: Asia/Shanghai 37 | restart: always 38 | 39 | tomcat02: 40 | build: 41 | context: tomcat 42 | dockerfile: Dockerfile 43 | hostname: tomcat02.magedu.com 44 | ports: 45 | - 8089:8080 46 | volumes: 47 | - tomcat02_apps:/usr/local/tomcat/webapps 48 | - ./tomcat/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml 49 | networks: 50 | tomcat_net: 51 | ipv4_address: 172.31.4.12 52 | aliases: 53 | - tomcat02 54 | - tomcat 55 | environment: 56 | TZ: Asia/Shanghai 57 | restart: always 58 | 59 | tomcat03: 60 | build: 61 | context: tomcat 62 | dockerfile: Dockerfile 63 | hostname: tomcat03.magedu.com 64 | ports: 65 | - 8090:8080 66 | volumes: 67 | - tomcat03_apps:/usr/local/tomcat/webapps 68 | - ./tomcat/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml 69 | networks: 70 | tomcat_net: 71 | ipv4_address: 172.31.4.13 72 | aliases: 73 | - tomcat03 74 | - tomcat 75 | environment: 76 | TZ: Asia/Shanghai 77 | restart: always 78 | -------------------------------------------------------------------------------- /07-jenkins-agents/docker-compose-ssh-agent.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | 3 | volumes: 4 | ssh_agent01_data: {} 5 | ssh_agent02_data: {} 6 | 7 | networks: 8 | jenkins_net: 9 | driver: bridge 10 | ipam: 11 | config: 12 | - subnet: 172.31.9.0/24 13 | 14 | services: 15 | ssh-agent01: 16 | image: jenkins/ssh-agent:jdk11 17 | hostname: ssh-agent01.magedu.com 18 | #user: jenkins 19 | environment: 20 | TZ: Asia/Shanghai 21 | #JENKINS_AGENT_HOME: /home/jenkins 22 | JENKINS_AGENT_SSH_PUBKEY: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6z4ELkY56/vIIhmCPNE2FolKlskP6OEsyGIfS3TVhHTpXOTjsc37C8BHo997rEIlyXGvPG36xQDd1dxsz2dz0Rs0e60iUsdT7JwQjLgW/6szX9W0EmNWiUz9od6Gt+onCC4jd9yK2zdDDc+E6ML5WihAGm7dmKU3l3FrBa1oYgDa6Jig/sL0Wl5+3gOJPzUrxX438FRkORVnDFEz37Da8RUf+8vcI/6eQ5loUDp0/qTPpDqhC98He6JPwr31Jenx8ULdrsPZH5Og2KYX801aVpw6DTiC+uZm9gyw1ysqSGCXgBkrh/IB9rdvl3szzWseLZg+Nj84j1d3LUN/oXj1N 23 | # SSH PRIVATE KEY and PUBLIC KEY is generated by you. 24 | networks: 25 | jenkins_net: 26 | ipv4_address: 172.31.9.21 27 | aliases: 28 | - ssh-slave01 29 | - ssh-agent01 30 | ports: 31 | - "22022:22" 32 | #restart: always 33 | 34 | ssh-agent02: 35 | image: jenkins/ssh-agent:jdk11 36 | hostname: ssh-agent02.magedu.com 37 | #user: jenkins 38 | environment: 39 | TZ: Asia/Shanghai 40 | #JENKINS_AGENT_HOME: /home/jenkins 41 | JENKINS_AGENT_SSH_PUBKEY: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6z4ELkY56/vIIhmCPNE2FolKlskP6OEsyGIfS3TVhHTpXOTjsc37C8BHo997rEIlyXGvPG36xQDd1dxsz2dz0Rs0e60iUsdT7JwQjLgW/6szX9W0EmNWiUz9od6Gt+onCC4jd9yK2zdDDc+E6ML5WihAGm7dmKU3l3FrBa1oYgDa6Jig/sL0Wl5+3gOJPzUrxX438FRkORVnDFEz37Da8RUf+8vcI/6eQ5loUDp0/qTPpDqhC98He6JPwr31Jenx8ULdrsPZH5Og2KYX801aVpw6DTiC+uZm9gyw1ysqSGCXgBkrh/IB9rdvl3szzWseLZg+Nj84j1d3LUN/oXj1N 42 | # SSH PRIVATE KEY and PUBLIC KEY is generated by you. 43 | networks: 44 | jenkins_net: 45 | ipv4_address: 172.31.9.22 46 | aliases: 47 | - ssh-slave02 48 | - ssh-agent02 49 | ports: 50 | - "22122:22" 51 | #restart: always 52 | -------------------------------------------------------------------------------- /09-argocd-and-rollout/rollout-demos/01-basic-rollouts-demo.yaml: -------------------------------------------------------------------------------- 1 | # CopyRight: MageEdu 2 | # 3 | --- 4 | apiVersion: argoproj.io/v1alpha1 5 | kind: Rollout 6 | metadata: 7 | name: rollouts-spring-boot-helloworld 8 | spec: 9 | replicas: 10 10 | strategy: 11 | canary: 12 | steps: 13 | - setWeight: 10 14 | - pause: {} 15 | - setWeight: 20 16 | - pause: {duration: 20} 17 | - setWeight: 30 18 | - pause: {duration: 20} 19 | - setWeight: 40 20 | - pause: {duration: 20} 21 | - setWeight: 60 22 | - pause: {duration: 20} 23 | - setWeight: 80 24 | - pause: {duration: 20} 25 | revisionHistoryLimit: 5 26 | selector: 27 | matchLabels: 28 | app: spring-boot-helloworld 29 | template: 30 | metadata: 31 | labels: 32 | app: spring-boot-helloworld 33 | spec: 34 | containers: 35 | - name: spring-boot-helloworld 36 | image: ikubernetes/spring-boot-helloworld:v0.9.2 37 | ports: 38 | - name: http 39 | containerPort: 80 40 | protocol: TCP 41 | resources: 42 | requests: 43 | memory: 32Mi 44 | cpu: 50m 45 | livenessProbe: 46 | httpGet: 47 | path: '/' 48 | port: 80 49 | scheme: HTTP 50 | initialDelaySeconds: 3 51 | readinessProbe: 52 | httpGet: 53 | path: '/' 54 | port: 80 55 | scheme: HTTP 56 | initialDelaySeconds: 5 57 | --- 58 | apiVersion: v1 59 | kind: Service 60 | metadata: 61 | name: spring-boot-helloworld 62 | spec: 63 | ports: 64 | - port: 80 65 | targetPort: http 66 | protocol: TCP 67 | name: http 68 | selector: 69 | app: spring-boot-helloworld 70 | --- 71 | apiVersion: networking.k8s.io/v1 72 | kind: Ingress 73 | metadata: 74 | name: spring-boot-helloworld 75 | spec: 76 | ingressClassName: "nginx" 77 | rules: 78 | - host: hello.magedu.com 79 | http: 80 | paths: 81 | - path: / 82 | pathType: Prefix 83 | backend: 84 | service: 85 | name: spring-boot-helloworld 86 | port: 87 | number: 80 88 | --- 89 | -------------------------------------------------------------------------------- /06-jenkins-distributed-build/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | 3 | volumes: 4 | jenkins01_data: {} 5 | slave01_data: {} 6 | slave01_remote_data: {} 7 | slave02_data: {} 8 | slave02_remote_data: {} 9 | 10 | networks: 11 | jenkins_net: 12 | driver: bridge 13 | ipam: 14 | config: 15 | - subnet: 172.31.8.0/24 16 | 17 | services: 18 | jenkins01: 19 | image: jenkins/jenkins:jdk17 20 | hostname: master01.magedu.com 21 | user: root 22 | env_file: 23 | - conf/environments 24 | environment: 25 | TZ: Asia/Shanghai 26 | volumes: 27 | - jenkins01_data:/var/jenkins_home/ 28 | ports: 29 | - 8080:8080 30 | - 50000:50000 31 | networks: 32 | jenkins_net: 33 | ipv4_address: 172.31.8.2 34 | aliases: 35 | - jenkins_master 36 | - master 37 | - jenkins_master01 38 | - master01 39 | extra_hosts: 40 | #- "jenkins.magedu.com:${JENKINS_HOST_IP}" 41 | - "reg.magedu.com:${HARBOR_HOST_IP}" 42 | - "gitlab.magedu.com:${GITLAB_HOST_IP}" 43 | - "tomcat.magedu.com:${TOMCAT_HOST_IP}" 44 | - "sonar.magedu.com:${SONAR_HOST_IP}" 45 | restart: always 46 | 47 | slave01: 48 | image: jenkins/jenkins:jdk17 49 | hostname: slave01.magedu.com 50 | user: root 51 | env_file: 52 | - conf/environments 53 | environment: 54 | TZ: Asia/Shanghai 55 | volumes: 56 | - slave01_data:/var/jenkins_home/ 57 | - slave01_remote_data:/appdata/jenkins/ 58 | ports: 59 | - 8081:8080 60 | networks: 61 | jenkins_net: 62 | ipv4_address: 172.31.8.11 63 | aliases: 64 | - jenkins_slave 65 | - slave 66 | - slave01 67 | - jenkins_slave01 68 | - node01 69 | restart: always 70 | 71 | slave02: 72 | image: jenkins/jenkins:jdk17 73 | hostname: slave02.magedu.com 74 | user: root 75 | env_file: 76 | - conf/environments 77 | environment: 78 | TZ: Asia/Shanghai 79 | volumes: 80 | - slave02_data:/var/jenkins_home/ 81 | - slave02_remote_data:/appdata/jenkins/ 82 | ports: 83 | - 8082:8080 84 | networks: 85 | jenkins_net: 86 | ipv4_address: 172.31.8.12 87 | aliases: 88 | - jenkins_slave 89 | - slave 90 | - slave02 91 | - jenkins_slave02 92 | - node02 93 | restart: always 94 | -------------------------------------------------------------------------------- /07-jenkins-agents/ssh_keys/id_rsa: -------------------------------------------------------------------------------- 1 | -----BEGIN OPENSSH PRIVATE KEY----- 2 | b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn 3 | NhAAAAAwEAAQAAAYEAyJjPdxwMjBeXifELMmjJIjjdIfE9IS136IQpu9+Bnem//Q/zceaa 4 | GlL63yYL55Mty3aIM18C1JnVXMufPIkwrdbtIEyCeu2G0g1LXWR5+iNlDAL1Zrese7fmY0 5 | 0v3dQiRF/5ljiEiIA88QUM9WvR7LZHyB+DEAo3cWjpgBUeuR/MKDSfkARXAX+tL0TfW17X 6 | 0A4NlO6RR3XDQo1LNB4Zz7MekLS1zxKwJ3VRVC4yzyS8w/MzvrwsqiW0hZW8g9vfJSu0Jh 7 | neg22Lhx2Y8wK0Wfa6x67hV1vD+8Hj/oyAJK5pu9r8dFrL03/U/1c5OAXfZRzPH+ILuPy4 8 | Xh8L4TDFJPXq4KmNOs7cvMiQu9Eh8NWSdgc7iqYG4T7oD0c6W80YQdheCpKxoEbPdbPzP4 9 | wrODTQuwApPr4isdCxa8nVrAst+7kEZ1DRUr93cYMcC+CCKXn8mZnxExhqSILQl2y/cz3r 10 | R/DlCl3/nLt3FmHh20H4ojcvxWshlzfqXhlRYS1nAAAFkDKAmgIygJoCAAAAB3NzaC1yc2 11 | EAAAGBAMiYz3ccDIwXl4nxCzJoySI43SHxPSEtd+iEKbvfgZ3pv/0P83HmmhpS+t8mC+eT 12 | Lct2iDNfAtSZ1VzLnzyJMK3W7SBMgnrthtINS11kefojZQwC9Wa3rHu35mNNL93UIkRf+Z 13 | Y4hIiAPPEFDPVr0ey2R8gfgxAKN3Fo6YAVHrkfzCg0n5AEVwF/rS9E31te19AODZTukUd1 14 | w0KNSzQeGc+zHpC0tc8SsCd1UVQuMs8kvMPzM768LKoltIWVvIPb3yUrtCYZ3oNti4cdmP 15 | MCtFn2useu4Vdbw/vB4/6MgCSuabva/HRay9N/1P9XOTgF32Uczx/iC7j8uF4fC+EwxST1 16 | 6uCpjTrO3LzIkLvRIfDVknYHO4qmBuE+6A9HOlvNGEHYXgqSsaBGz3Wz8z+MKzg00LsAKT 17 | 6+IrHQsWvJ1awLLfu5BGdQ0VK/d3GDHAvggil5/JmZ8RMYakiC0Jdsv3M960fw5Qpd/5y7 18 | dxZh4dtB+KI3L8VrIZc36l4ZUWEtZwAAAAMBAAEAAAGAXyku8oBZ63OdrhCtkSJomFWFgf 19 | 6hU0XwpltcOQYUxUcIjxKsGJKe9HH9FTNFXnxRsz3t6wDdpOG9eCIYzmz+rNlS8ImbNJnN 20 | 5YPtBscNnn6AByy4IhxsNNzO7LjHRmLGRs2I55y0MtUzE9ujhCG8GqF2eBeK42cVWjW838 21 | glJQlSnpgoQfftFobtL4lqtDvQAaFJDCgIv2+8S6wfyv+kmwWMMHWp8iwZaP6csGSiMeZp 22 | rkOHfqpiPe1ZMC4SmjMJVlPjdZlC6vuXZkGbYsKkREqM3neEOh6WToaeGVY1b2bdnXi6Vk 23 | 6278l4EYjeaFxoebbjkSOeUreWucnX6nqph9zmgEXj50TydK8Z6K3YtswCBndT3GtanltR 24 | 3ukjQe3CUNqx8hmoFrfTu9VRvqjLDs/6DSci9CXfZqBoJK5a7L8cPCYE7yTz1mAMTQSg3U 25 | FKJw3V6RVJDhCe+DMbYV0seIHr8xc4GkHc9TCaHJFCWt4jiqOK3Z+NnqAMx0bU41ORAAAA 26 | wQCSdiFnSCueknUrxZpCn3PB/gP3PycjX+Nsd1jx6qZSAbH029bdGkV3kXzvzbR1PZYnLX 27 | mCKq8D4vAFdCqIF6TkIfesGlN/aSxXRVI9alL6Jbzc4xy3hFyeaWNMcsaQXGQ0kiqsvC/7 28 | XhIZumyNhJIoIbuw9hyzCdQYW4BZj7sEyyXmXukud0gJCpj2HvqObyZHavHAapqC2mDguQ 29 | 9gmZ3Q+0xvvfgscsVA5a/SZlUlkVYTHrrwxDAQC6+4MwFBUnwAAADBAP+sH7pQ9PNZbsIw 30 | bxD4/FYP0mLtl6mUK/HSHfcRXK+L3HzDDBFOUIqXc3lLwjSlsPPYoOAyoI0aHYUHNytPga 31 | 2W5FQNXRMKhZtfuLzfwyZIrbO+toTCyXuag0h5TQ1V0idr04kpGdtU2XjfFrUtgNT6CWNX 32 | seAGzxVtJem9RzLAa4IYiM3CVh07YAyfF15ac+eApfWpZt4ofAcs4BNgs8UR+5CpIfacEs 33 | UZTzXBZDbqcDruGDjalBOnELIEOPER6wAAAMEAyNqeTmY/FK1hPupZuGwbygJVnprk+mIx 34 | 6NxRvy68UddERcbd94CB0Y75w9OBivPg/a4xcYIzeQo7c8JDkpEtk1jpr+YDnY7N2oiW+x 35 | Mm3AilbzCBkRWXZhZaQF1/E0U5f/nMt9O6xyLaAsBcpdFrTP0lqeQdGLgOD6K+d+7zIrOK 36 | HDM05EptFbM8D23PRaPmsq7pANPZ1iG9I9LnkdOTvoV8wj0UqmCFguyMha110YbkcEB3d6 37 | m0xd63p3l377d1AAAAFXJvb3RAbGFiMDMubWFnZWR1LmNvbQECAwQF 38 | -----END OPENSSH PRIVATE KEY----- 39 | -------------------------------------------------------------------------------- /09-argocd-and-rollout/rollout-demos/02-rollouts-with-ingress-nginx-traffic-shifting.yaml: -------------------------------------------------------------------------------- 1 | # CopyRight: MageEdu 2 | --- 3 | apiVersion: argoproj.io/v1alpha1 4 | kind: Rollout 5 | metadata: 6 | name: rollouts-helloworld-with-traffic-shifting 7 | spec: 8 | replicas: 10 9 | strategy: 10 | canary: 11 | canaryService: spring-boot-helloworld-canary 12 | stableService: spring-boot-helloworld 13 | trafficRouting: 14 | nginx: 15 | stableIngress: spring-boot-helloworld 16 | steps: 17 | - setCanaryScale: 18 | matchTrafficWeight: true 19 | - setWeight: 5 20 | - pause: {duration: 1m} 21 | - setWeight: 10 22 | - pause: {duration: 1m} 23 | - pause: {duration: 20} 24 | - setWeight: 20 25 | - pause: {duration: 40} 26 | - setWeight: 40 27 | - pause: {duration: 20} 28 | - setWeight: 60 29 | - pause: {duration: 20} 30 | - setWeight: 80 31 | - pause: {duration: 20} 32 | revisionHistoryLimit: 5 33 | selector: 34 | matchLabels: 35 | app: spring-boot-helloworld 36 | template: 37 | metadata: 38 | labels: 39 | app: spring-boot-helloworld 40 | spec: 41 | containers: 42 | - name: spring-boot-helloworld 43 | image: ikubernetes/spring-boot-helloworld:v0.9.2 44 | ports: 45 | - name: http 46 | containerPort: 80 47 | protocol: TCP 48 | resources: 49 | requests: 50 | memory: 32Mi 51 | cpu: 50m 52 | livenessProbe: 53 | httpGet: 54 | path: '/' 55 | port: 80 56 | scheme: HTTP 57 | initialDelaySeconds: 3 58 | readinessProbe: 59 | httpGet: 60 | path: '/' 61 | port: 80 62 | scheme: HTTP 63 | initialDelaySeconds: 5 64 | --- 65 | apiVersion: v1 66 | kind: Service 67 | metadata: 68 | name: spring-boot-helloworld 69 | spec: 70 | ports: 71 | - port: 80 72 | targetPort: http 73 | protocol: TCP 74 | name: http 75 | selector: 76 | app: spring-boot-helloworld 77 | --- 78 | apiVersion: v1 79 | kind: Service 80 | metadata: 81 | name: spring-boot-helloworld-canary 82 | spec: 83 | ports: 84 | - port: 80 85 | targetPort: http 86 | protocol: TCP 87 | name: http 88 | selector: 89 | app: spring-boot-helloworld 90 | --- 91 | apiVersion: networking.k8s.io/v1 92 | kind: Ingress 93 | metadata: 94 | name: spring-boot-helloworld 95 | spec: 96 | ingressClassName: "nginx" 97 | rules: 98 | - host: hello.magedu.com 99 | http: 100 | paths: 101 | - path: / 102 | pathType: Prefix 103 | backend: 104 | service: 105 | name: spring-boot-helloworld 106 | port: 107 | number: 80 108 | --- 109 | -------------------------------------------------------------------------------- /04-tomcat-with-manager/tomcat/tomcat-users.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 22 | 38 | 42 | 49 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /09-argocd-and-rollout/rollout-demos/05-rollouts-bluegreen-with-analysis.yaml: -------------------------------------------------------------------------------- 1 | # CopyRight: MageEdu 2 | --- 3 | apiVersion: argoproj.io/v1alpha1 4 | kind: AnalysisTemplate 5 | metadata: 6 | name: success-rate 7 | spec: 8 | args: 9 | - name: service-name 10 | - name: namespace 11 | metrics: 12 | - name: success-rate 13 | # NOTE: prometheus queries return results in the form of a vector. 14 | # So it is common to access the index 0 of the returned array to obtain the value 15 | successCondition: result[0] >= 0.95 16 | interval: 20s 17 | count: 3 18 | failureLimit: 3 19 | provider: 20 | prometheus: 21 | address: http://prometheus.prom.svc.cluster.local:9090 22 | query: | 23 | sum(irate(nginx_ingress_controller_requests{service=~"{{args.service-name}}",namespace=~"{{args.namespace}}",status!~"[4-5].*"}[1m])) / 24 | sum(irate(nginx_ingress_controller_requests{service=~"{{args.service-name}}",namespace=~"{{args.namespace}}"}[1m])) 25 | --- 26 | apiVersion: argoproj.io/v1alpha1 27 | kind: Rollout 28 | metadata: 29 | name: rollout-helloworld-bluegreen-with-analysis 30 | spec: 31 | replicas: 3 32 | revisionHistoryLimit: 5 33 | selector: 34 | matchLabels: 35 | app: rollout-helloworld-bluegreen 36 | template: 37 | metadata: 38 | labels: 39 | app: rollout-helloworld-bluegreen 40 | spec: 41 | containers: 42 | - name: spring-boot-helloworld 43 | image: ikubernetes/spring-boot-helloworld:v0.9.2 44 | ports: 45 | - containerPort: 80 46 | strategy: 47 | blueGreen: 48 | activeService: spring-boot-helloworld 49 | previewService: spring-boot-helloworld-preview 50 | prePromotionAnalysis: 51 | templates: 52 | - templateName: success-rate 53 | args: 54 | - name: service-name 55 | value: spring-boot-helloworld 56 | - name: namespace 57 | value: default 58 | postPromotionAnalysis: 59 | templates: 60 | - templateName: success-rate 61 | args: 62 | - name: service-name 63 | value: spring-boot-helloworld 64 | - name: namespace 65 | value: default 66 | autoPromotionEnabled: true 67 | --- 68 | kind: Service 69 | apiVersion: v1 70 | metadata: 71 | name: spring-boot-helloworld 72 | spec: 73 | selector: 74 | app: rollout-helloworld-bluegreen 75 | ports: 76 | - protocol: TCP 77 | port: 80 78 | targetPort: 80 79 | --- 80 | kind: Service 81 | apiVersion: v1 82 | metadata: 83 | name: spring-boot-helloworld-preview 84 | spec: 85 | selector: 86 | app: rollout-helloworld-bluegreen 87 | ports: 88 | - protocol: TCP 89 | port: 80 90 | targetPort: 80 91 | --- 92 | apiVersion: networking.k8s.io/v1 93 | kind: Ingress 94 | metadata: 95 | name: spring-boot-helloworld 96 | spec: 97 | ingressClassName: "nginx" 98 | rules: 99 | - host: hello.magedu.com 100 | http: 101 | paths: 102 | - path: / 103 | pathType: Prefix 104 | backend: 105 | service: 106 | name: spring-boot-helloworld 107 | port: 108 | number: 80 109 | --- 110 | -------------------------------------------------------------------------------- /02-gitlab-ce-basics/gitlab/environments: -------------------------------------------------------------------------------- 1 | DEBUG=false 2 | 3 | DB_ADAPTER=postgresql 4 | DB_HOST=postgresql 5 | DB_PORT=5432 6 | DB_USER=gitlab 7 | DB_PASS=MageEdu.C0m 8 | DB_NAME=gitlabhq_production 9 | 10 | REDIS_HOST=redis 11 | REDIS_PORT=6379 12 | 13 | TZ=Asia/Shanghai 14 | GITLAB_TIMEZONE=Asia/Shanghai 15 | 16 | GITLAB_HTTPS=false 17 | SSL_SELF_SIGNED=false 18 | 19 | GITLAB_HOST=gitlab.magedu.com 20 | GITLAB_PORT=80 21 | GITLAB_SSH_PORT=10022 22 | GITLAB_RELATIVE_URL_ROOT= 23 | GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alphanumeric-string 24 | GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alphanumeric-string 25 | GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alphanumeric-string 26 | 27 | GITLAB_ROOT_PASSWORD=magedu.com 28 | GITLAB_ROOT_EMAIL=mage@magedu.com 29 | 30 | GITLAB_NOTIFY_ON_BROKEN_BUILDS=true 31 | GITLAB_NOTIFY_PUSHER=false 32 | 33 | GITLAB_EMAIL=notifications@magedu.com 34 | GITLAB_EMAIL_REPLY_TO=noreply@magedu.com 35 | GITLAB_INCOMING_EMAIL_ADDRESS=reply@magedu.com 36 | 37 | GITLAB_BACKUP_SCHEDULE=daily 38 | GITLAB_BACKUP_TIME=01:00 39 | 40 | SMTP_ENABLED=false 41 | SMTP_DOMAIN=mail.magedu.com 42 | SMTP_HOST=smtp.magedu.com 43 | SMTP_PORT=587 44 | SMTP_USER=mailer@magedu.com 45 | SMTP_PASS=password 46 | SMTP_STARTTLS=true 47 | SMTP_AUTHENTICATION=login 48 | 49 | IMAP_ENABLED=false 50 | IMAP_HOST=imap.magedu.com 51 | IMAP_PORT=993 52 | IMAP_USER=mailer@magedu.com 53 | IMAP_PASS=password 54 | IMAP_SSL=true 55 | IMAP_STARTTLS=false 56 | 57 | OAUTH_ENABLED=false 58 | OAUTH_AUTO_SIGN_IN_WITH_PROVIDER= 59 | OAUTH_ALLOW_SSO= 60 | OAUTH_BLOCK_AUTO_CREATED_USERS=true 61 | OAUTH_AUTO_LINK_LDAP_USER=false 62 | OAUTH_AUTO_LINK_SAML_USER=false 63 | OAUTH_EXTERNAL_PROVIDERS= 64 | 65 | OAUTH_CAS3_LABEL=cas3 66 | OAUTH_CAS3_SERVER= 67 | OAUTH_CAS3_DISABLE_SSL_VERIFICATION=false 68 | OAUTH_CAS3_LOGIN_URL=/cas/login 69 | OAUTH_CAS3_VALIDATE_URL=/cas/p3/serviceValidate 70 | OAUTH_CAS3_LOGOUT_URL=/cas/logout 71 | 72 | OAUTH_GOOGLE_API_KEY= 73 | OAUTH_GOOGLE_APP_SECRET= 74 | OAUTH_GOOGLE_RESTRICT_DOMAIN= 75 | 76 | OAUTH_FACEBOOK_API_KEY= 77 | OAUTH_FACEBOOK_APP_SECRET= 78 | 79 | OAUTH_TWITTER_API_KEY= 80 | OAUTH_TWITTER_APP_SECRET= 81 | 82 | OAUTH_GITHUB_API_KEY= 83 | OAUTH_GITHUB_APP_SECRET= 84 | OAUTH_GITHUB_URL= 85 | OAUTH_GITHUB_VERIFY_SSL= 86 | 87 | OAUTH_GITLAB_API_KEY= 88 | OAUTH_GITLAB_APP_SECRET= 89 | 90 | OAUTH_BITBUCKET_API_KEY= 91 | OAUTH_BITBUCKET_APP_SECRET= 92 | OAUTH_BITBUCKET_URL= 93 | 94 | OAUTH_SAML_ASSERTION_CONSUMER_SERVICE_URL= 95 | OAUTH_SAML_IDP_CERT_FINGERPRINT= 96 | OAUTH_SAML_IDP_SSO_TARGET_URL= 97 | OAUTH_SAML_ISSUER= 98 | OAUTH_SAML_LABEL="Our SAML Provider" 99 | OAUTH_SAML_NAME_IDENTIFIER_FORMAT=urn:oasis:names:tc:SAML:2.0:nameid-format:transient 100 | OAUTH_SAML_GROUPS_ATTRIBUTE= 101 | OAUTH_SAML_EXTERNAL_GROUPS= 102 | OAUTH_SAML_ATTRIBUTE_STATEMENTS_EMAIL= 103 | OAUTH_SAML_ATTRIBUTE_STATEMENTS_NAME= 104 | OAUTH_SAML_ATTRIBUTE_STATEMENTS_USERNAME= 105 | OAUTH_SAML_ATTRIBUTE_STATEMENTS_FIRST_NAME= 106 | OAUTH_SAML_ATTRIBUTE_STATEMENTS_LAST_NAME= 107 | 108 | OAUTH_CROWD_SERVER_URL= 109 | OAUTH_CROWD_APP_NAME= 110 | OAUTH_CROWD_APP_PASSWORD= 111 | 112 | OAUTH_AUTH0_CLIENT_ID= 113 | OAUTH_AUTH0_CLIENT_SECRET= 114 | OAUTH_AUTH0_DOMAIN= 115 | OAUTH_AUTH0_SCOPE= 116 | 117 | OAUTH_AZURE_API_KEY= 118 | OAUTH_AZURE_API_SECRET= 119 | OAUTH_AZURE_TENANT_ID= 120 | -------------------------------------------------------------------------------- /09-argocd-and-rollout/README.md: -------------------------------------------------------------------------------- 1 | # Argo Rollouts Examples. 2 | 3 | Rollouts资源配置示例。 4 | 5 | ### 01. 基础配置示例 6 | 7 | 配置文件:01-basic-rollouts-demo.yaml 8 | 9 | ```bash 10 | kubectl apply -f 01-basic-rollouts-demo.yaml 11 | ``` 12 | 13 | #### 测试请求 14 | 15 | 向Ingress资源中指定的主机名hello.magedu.com发起测试请求... 16 | ```bash 17 | while true; do curl http://hello.magedu.com; echo; sleep 0.$[$RANDOM%10]; done 18 | ``` 19 | 20 | #### rollout 21 | 22 | ```bash 23 | kubectl argo rollouts set image rollouts-spring-boot-helloworld spring-boot-helloworld=ikubernetes/spring-boot-helloworld:v0.9.3 24 | ``` 25 | 26 | #### watch 27 | 28 | ```bash 29 | kubectl argo rollouts get rollout rollouts-spring-boot-helloworld --watch 30 | ``` 31 | 32 | #### Promote 33 | 34 | ```bash 35 | kubectl argo rollouts promote rollouts-spring-boot-helloworld 36 | ``` 37 | 38 | ### 02.基于Ingress Nginx的Canary发布和流量迁移 39 | 40 | 配置文件:02-rollouts-with-ingress-nginx-traffic-shifting.yaml 41 | 42 | **依赖项**: Ingress Nginx 43 | 44 | ```bash 45 | kubectl apply -f 02-rollouts-with-ingress-nginx-traffic-shifting.yaml 46 | ``` 47 | 48 | #### Client 49 | 向Ingress资源中指定的主机名hello.magedu.com发起测试请求... 50 | ```bash 51 | while true; do curl http://hello.magedu.com; echo; sleep 0.$[$RANDOM%10]; done 52 | ``` 53 | 54 | #### Rollout 55 | 56 | ```bash 57 | kubectl argo rollouts set image rollouts-helloworld-with-traffic-shifting spring-boot-helloworld=ikubernetes/spring-boot-helloworld:v0.9.3 58 | ``` 59 | 60 | ### 03.基于Prometheus和Ingress Nginx的渐进式交付 61 | 62 | 配置文件:03-rollouts-with-prometheus-analysis.yaml 63 | 64 | **依赖项**: Ingress Nginx 65 | 66 | ```bash 67 | kubectl apply -f 03-rollouts-with-prometheus-analysis.yaml 68 | ``` 69 | #### client 70 | 71 | 向Ingress资源中指定的主机名hello.magedu.com发起测试请求... 72 | 73 | ```bash 74 | while true; do curl http://hello.magedu.com; echo; sleep 0.$[$RANDOM%10]; done 75 | ``` 76 | 77 | #### Prometheus Metrics 78 | 79 | ``` 80 | irate(nginx_ingress_controller_requests{service=~"spring-boot-helloworld",namespace=~"default",status!~"[4-5].*"}[1m]) 81 | ``` 82 | 83 | ``` 84 | irate(nginx_ingress_controller_requests{service=~"spring-boot-helloworld",namespace=~"default"}[1m]) 85 | ``` 86 | 87 | Successful Rate: 88 | 89 | ``` 90 | sum(irate(nginx_ingress_controller_requests{service=~"spring-boot-helloworld",namespace=~"default",status!~"[4-5].*"}[1m]))/sum(irate(nginx_ingress_controller_requests{service=~"spring-boot-helloworld",namespace=~"default"}[1m])) 91 | ``` 92 | 93 | 94 | #### Rollout 95 | 96 | ```bash 97 | kubectl argo rollouts set image rollouts-helloworld-with-analysis spring-boot-helloworld=ikubernetes/spring-boot-helloworld:v0.9.3 98 | ``` 99 | 100 | ### Blue Green Rollout 101 | 102 | 资源配置文件:04-rollouts-bluegreen-demo.yaml 103 | 104 | #### Deploy 105 | 106 | ```bash 107 | kubectl apply -f 04-rollouts-bluegreen-demo.yaml 108 | ``` 109 | 110 | #### client 111 | 112 | send requests... 113 | ```bash 114 | while true; do curl http://hello.magedu.com; echo; sleep 0.$[$RANDOM%10]; done 115 | ``` 116 | 117 | #### Rollout 118 | 119 | ```bash 120 | kubectl argo rollouts set image rollout-helloworld-bluegreen spring-boot-helloworld=ikubernetes/spring-boot-helloworld:v0.9.3 121 | ``` 122 | 123 | #### Promote 124 | 125 | ```bash 126 | kubectl argo rollouts promote rollout-helloworld-bluegreen 127 | ``` 128 | 129 | ### Blue Green Rollout with Analysis 130 | 131 | 配置文件:05-rollouts-bluegreen-with-analysis.yaml 132 | 133 | #### Deploy 134 | 135 | ```bash 136 | kubectl apply -f 05-rollouts-bluegreen-with-analysis.yaml 137 | ``` 138 | 139 | #### client 140 | 141 | send requests... 142 | ```bash 143 | while true; do curl http://hello.magedu.com; echo; sleep 0.$[$RANDOM%10]; done 144 | ``` 145 | 146 | #### Rollout 147 | 148 | ```bash 149 | kubectl argo rollouts set image rollout-helloworld-bluegreen-with-analysis spring-boot-helloworld=ikubernetes/spring-boot-helloworld:v0.9.3 150 | ``` 151 | -------------------------------------------------------------------------------- /09-argocd-and-rollout/rollout-demos/03-rollouts-with-prometheus-analysis.yaml: -------------------------------------------------------------------------------- 1 | # CopyRight: MageEdu 2 | # 3 | --- 4 | apiVersion: argoproj.io/v1alpha1 5 | kind: AnalysisTemplate 6 | metadata: 7 | name: success-rate 8 | spec: 9 | args: 10 | - name: service-name 11 | - name: namespace 12 | metrics: 13 | - name: success-rate 14 | # NOTE: prometheus queries return results in the form of a vector. 15 | # So it is common to access the index 0 of the returned array to obtain the value 16 | successCondition: result[0] >= 0.95 17 | interval: 20s 18 | count: 5 19 | failureLimit: 3 20 | provider: 21 | prometheus: 22 | address: http://prometheus.prom.svc.cluster.local:9090 23 | query: | 24 | sum(irate(nginx_ingress_controller_requests{service=~"{{args.service-name}}",namespace=~"{{args.namespace}}",status!~"[4-5].*"}[1m])) / 25 | sum(irate(nginx_ingress_controller_requests{service=~"{{args.service-name}}",namespace=~"{{args.namespace}}"}[1m])) 26 | --- 27 | apiVersion: argoproj.io/v1alpha1 28 | kind: Rollout 29 | metadata: 30 | name: rollouts-helloworld-with-analysis 31 | spec: 32 | replicas: 10 33 | strategy: 34 | canary: 35 | analysis: 36 | templates: 37 | - templateName: success-rate 38 | args: 39 | - name: service-name 40 | value: spring-boot-helloworld 41 | - name: namespace 42 | value: default 43 | canaryService: spring-boot-helloworld-canary 44 | stableService: spring-boot-helloworld 45 | trafficRouting: 46 | nginx: 47 | stableIngress: spring-boot-helloworld 48 | steps: 49 | - setCanaryScale: 50 | matchTrafficWeight: true 51 | - setWeight: 5 52 | - pause: {duration: 2m} 53 | - setWeight: 10 54 | - pause: {duration: 1m} 55 | - setWeight: 20 56 | - pause: {duration: 40} 57 | - setWeight: 40 58 | - pause: {duration: 20} 59 | - setWeight: 60 60 | - pause: {duration: 20} 61 | - setWeight: 80 62 | - pause: {duration: 20} 63 | revisionHistoryLimit: 5 64 | selector: 65 | matchLabels: 66 | app: spring-boot-helloworld 67 | template: 68 | metadata: 69 | labels: 70 | app: spring-boot-helloworld 71 | spec: 72 | containers: 73 | - name: spring-boot-helloworld 74 | image: ikubernetes/spring-boot-helloworld:v0.9.2 75 | ports: 76 | - name: http 77 | containerPort: 80 78 | protocol: TCP 79 | resources: 80 | requests: 81 | memory: 32Mi 82 | cpu: 50m 83 | livenessProbe: 84 | httpGet: 85 | path: '/' 86 | port: 80 87 | scheme: HTTP 88 | initialDelaySeconds: 3 89 | readinessProbe: 90 | httpGet: 91 | path: '/' 92 | port: 80 93 | scheme: HTTP 94 | initialDelaySeconds: 5 95 | --- 96 | apiVersion: v1 97 | kind: Service 98 | metadata: 99 | name: spring-boot-helloworld 100 | spec: 101 | ports: 102 | - port: 80 103 | targetPort: http 104 | protocol: TCP 105 | name: http 106 | selector: 107 | app: spring-boot-helloworld 108 | --- 109 | apiVersion: v1 110 | kind: Service 111 | metadata: 112 | name: spring-boot-helloworld-canary 113 | spec: 114 | ports: 115 | - port: 80 116 | targetPort: http 117 | protocol: TCP 118 | name: http 119 | selector: 120 | app: spring-boot-helloworld 121 | --- 122 | apiVersion: networking.k8s.io/v1 123 | kind: Ingress 124 | metadata: 125 | name: spring-boot-helloworld 126 | spec: 127 | ingressClassName: "nginx" 128 | rules: 129 | - host: hello.magedu.com 130 | http: 131 | paths: 132 | - path: / 133 | pathType: Prefix 134 | backend: 135 | service: 136 | name: spring-boot-helloworld 137 | port: 138 | number: 80 139 | --- 140 | -------------------------------------------------------------------------------- /08-jenkins-on-kubernetes/static-token-auth-example/kube-apiserver.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | annotations: 5 | kubeadm.kubernetes.io/kube-apiserver.advertise-address.endpoint: 172.29.6.1:6443 6 | creationTimestamp: null 7 | labels: 8 | component: kube-apiserver 9 | tier: control-plane 10 | name: kube-apiserver 11 | namespace: kube-system 12 | spec: 13 | containers: 14 | - command: 15 | - kube-apiserver 16 | - --advertise-address=172.29.6.1 17 | - --allow-privileged=true 18 | - --authorization-mode=Node,RBAC 19 | - --token-auth-file=/etc/kubernetes/auth/tokens.csv 20 | - --client-ca-file=/etc/kubernetes/pki/ca.crt 21 | - --enable-admission-plugins=NodeRestriction 22 | - --enable-bootstrap-token-auth=true 23 | - --etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt 24 | - --etcd-certfile=/etc/kubernetes/pki/apiserver-etcd-client.crt 25 | - --etcd-keyfile=/etc/kubernetes/pki/apiserver-etcd-client.key 26 | - --etcd-servers=https://127.0.0.1:2379 27 | - --kubelet-client-certificate=/etc/kubernetes/pki/apiserver-kubelet-client.crt 28 | - --kubelet-client-key=/etc/kubernetes/pki/apiserver-kubelet-client.key 29 | - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname 30 | - --proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt 31 | - --proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key 32 | - --requestheader-allowed-names=front-proxy-client 33 | - --requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt 34 | - --requestheader-extra-headers-prefix=X-Remote-Extra- 35 | - --requestheader-group-headers=X-Remote-Group 36 | - --requestheader-username-headers=X-Remote-User 37 | - --secure-port=6443 38 | - --service-account-issuer=https://kubernetes.default.svc.cluster.local 39 | - --service-account-key-file=/etc/kubernetes/pki/sa.pub 40 | - --service-account-signing-key-file=/etc/kubernetes/pki/sa.key 41 | - --service-cluster-ip-range=10.96.0.0/12 42 | - --tls-cert-file=/etc/kubernetes/pki/apiserver.crt 43 | - --tls-private-key-file=/etc/kubernetes/pki/apiserver.key 44 | image: registry.k8s.io/kube-apiserver:v1.25.4 45 | imagePullPolicy: IfNotPresent 46 | livenessProbe: 47 | failureThreshold: 8 48 | httpGet: 49 | host: 172.29.6.1 50 | path: /livez 51 | port: 6443 52 | scheme: HTTPS 53 | initialDelaySeconds: 10 54 | periodSeconds: 10 55 | timeoutSeconds: 15 56 | name: kube-apiserver 57 | readinessProbe: 58 | failureThreshold: 3 59 | httpGet: 60 | host: 172.29.6.1 61 | path: /readyz 62 | port: 6443 63 | scheme: HTTPS 64 | periodSeconds: 1 65 | timeoutSeconds: 15 66 | resources: 67 | requests: 68 | cpu: 250m 69 | startupProbe: 70 | failureThreshold: 24 71 | httpGet: 72 | host: 172.29.6.1 73 | path: /livez 74 | port: 6443 75 | scheme: HTTPS 76 | initialDelaySeconds: 10 77 | periodSeconds: 10 78 | timeoutSeconds: 15 79 | volumeMounts: 80 | - mountPath: /etc/ssl/certs 81 | name: ca-certs 82 | readOnly: true 83 | - mountPath: /etc/ca-certificates 84 | name: etc-ca-certificates 85 | readOnly: true 86 | - mountPath: /etc/pki 87 | name: etc-pki 88 | readOnly: true 89 | - mountPath: /etc/kubernetes/pki 90 | name: k8s-certs 91 | readOnly: true 92 | - mountPath: /usr/local/share/ca-certificates 93 | name: usr-local-share-ca-certificates 94 | readOnly: true 95 | - mountPath: /usr/share/ca-certificates 96 | name: usr-share-ca-certificates 97 | readOnly: true 98 | - mountPath: /etc/kubernetes/auth 99 | name: users-static-token 100 | readOnly: true 101 | hostNetwork: true 102 | priorityClassName: system-node-critical 103 | securityContext: 104 | seccompProfile: 105 | type: RuntimeDefault 106 | volumes: 107 | - hostPath: 108 | path: /etc/ssl/certs 109 | type: DirectoryOrCreate 110 | name: ca-certs 111 | - hostPath: 112 | path: /etc/ca-certificates 113 | type: DirectoryOrCreate 114 | name: etc-ca-certificates 115 | - hostPath: 116 | path: /etc/pki 117 | type: DirectoryOrCreate 118 | name: etc-pki 119 | - hostPath: 120 | path: /etc/kubernetes/pki 121 | type: DirectoryOrCreate 122 | name: k8s-certs 123 | - hostPath: 124 | path: /usr/local/share/ca-certificates 125 | type: DirectoryOrCreate 126 | name: usr-local-share-ca-certificates 127 | - hostPath: 128 | path: /usr/share/ca-certificates 129 | type: DirectoryOrCreate 130 | name: usr-share-ca-certificates 131 | - hostPath: 132 | path: /etc/kubernetes/auth 133 | type: DirectoryOrCreate 134 | name: users-static-token 135 | status: {} 136 | -------------------------------------------------------------------------------- /08-jenkins-on-kubernetes/README.md: -------------------------------------------------------------------------------- 1 | # 部署Jenkins 2 | deploy目录中的配置文件,用于将Jenkins部署于Kubernetes集群之上,它依赖于: 3 | - Kubernetes集群上部署有基于nfs-csi的存储服务,且创建了名称为nfs-csi的StorageClass资源,并支持PV的动态置备; 4 | - Kubernetes集群上部署有Ingress Nginx Controller; 5 | 6 | ### 部署命令 7 | ```bash 8 | kubectl apply -f deploy/ 9 | kubectl apply -f ingress/ 10 | ``` 11 | 12 | ### Pipeline代码示例 13 | 14 | #### 测试于Pod中运行slave 15 | 16 | ``` 17 | // Author: "MageEdu " 18 | // Site: www.magedu.com 19 | pipeline { 20 | agent { 21 | kubernetes { 22 | inheritFrom 'kube-agent' 23 | } 24 | } 25 | stages { 26 | stage('Testing...') { 27 | steps { 28 | sh 'java -version' 29 | } 30 | } 31 | } 32 | } 33 | ``` 34 | 35 | #### 测试maven构建环境 36 | 37 | 需要事先定义出名为maven-3.8.6的Pod Template 38 | 39 | ``` 40 | pipeline { 41 | agent { 42 | kubernetes { 43 | inheritFrom 'maven-3.8' 44 | } 45 | } 46 | stages { 47 | stage('Build...') { 48 | steps { 49 | container('maven') { 50 | sh 'mvn -version' 51 | } 52 | } 53 | } 54 | } 55 | } 56 | ``` 57 | 58 | #### 测试docker in docker环境 59 | 60 | 需要事行定义出名为maven-and-docker的Pod Template;另外,docker in docker依赖于hostPath类型的存储卷将节点上的/var/run/docker.sock带入到Pod的dind容器中; 61 | 62 | ``` 63 | pipeline { 64 | agent { 65 | kubernetes { 66 | inheritFrom 'maven-and-docker' 67 | } 68 | } 69 | stages { 70 | stage('maven version') { 71 | steps { 72 | container('maven') { 73 | sh 'mvn -version' 74 | } 75 | } 76 | } 77 | stage('docker info') { 78 | steps { 79 | container('dind') { 80 | sh 'docker info' 81 | } 82 | } 83 | } 84 | } 85 | } 86 | ``` 87 | 88 | ### 一个具有实际功用的Pipeline示例 89 | 90 | ``` 91 | pipeline { 92 | agent { 93 | kubernetes { 94 | inheritFrom 'maven-and-docker' 95 | } 96 | } 97 | triggers { 98 | GenericTrigger( 99 | genericVariables: [ 100 | [key: 'ref', value: '$.ref'] 101 | ], 102 | token: 'fClZ0e/kTcqL2ARh7YqxW/3ndOCZA2SqfKnRTLat', 103 | causeString: 'Triggered on $ref', 104 | printContributedVariables: true, 105 | printPostContent: true 106 | ) 107 | } 108 | environment { 109 | codeRepo="http://gitlab.magedu.com/root/spring-boot-helloWorld.git" 110 | registry='hub.magedu.com' 111 | registryUrl='https://hub.magedu.com' 112 | registryCredential='harbor-user-credential' 113 | projectName='spring-boot-helloworld' 114 | imageUrl="${registry}/ikubernetes/${projectName}" 115 | imageTag="${BUILD_ID}" 116 | } 117 | stages { 118 | stage('Source') { 119 | steps { 120 | git branch: 'main', credentialsId: 'gitlab-root-credential', url: "${codeRepo}" 121 | } 122 | } 123 | stage('Build') { 124 | steps { 125 | container('maven') { 126 | sh 'mvn -B -DskipTests clean package' 127 | } 128 | } 129 | } 130 | stage('Test') { 131 | steps { 132 | container('maven') { 133 | sh 'mvn test' 134 | } 135 | } 136 | } 137 | stage("SonarQube Analysis") { 138 | steps { 139 | container('maven') { 140 | withSonarQubeEnv('SonarQube-Server') { 141 | sh 'mvn sonar:sonar' 142 | } 143 | } 144 | } 145 | } 146 | stage("Quality Gate") { 147 | steps { 148 | timeout(time: 30, unit: 'MINUTES') { 149 | waitForQualityGate abortPipeline: true 150 | } 151 | } 152 | } 153 | stage('Build Image') { 154 | steps { 155 | container('dind') { 156 | script { 157 | dockerImage = docker.build("${imageUrl}:${imageTag}") 158 | } 159 | } 160 | } 161 | } 162 | stage('Push Image') { 163 | steps { 164 | container('dind') { 165 | script { 166 | docker.withRegistry(registryUrl, registryCredential) { 167 | dockerImage.push() 168 | dockerImage.push('latest') 169 | } 170 | } 171 | } 172 | } 173 | } 174 | stage('Update-manifests') { 175 | steps { 176 | container('jnlp') { 177 | sh 'sed -i "s#__IMAGE__#${imageUrl}:${imageTag}#gi" deploy/all-in-one.yaml' 178 | } 179 | } 180 | } 181 | stage('Deploy') { 182 | steps { 183 | container('kubectl') { 184 | withKubeConfig([credentialsId: 'k8s-hello-admin-token', serverUrl: 'https://kubernetes.default.svc']) { 185 | sh ''' 186 | kubectl create namespace hello 187 | kubectl apply -f deploy/all-in-one.yaml -n hello 188 | ''' 189 | } 190 | } 191 | } 192 | } 193 | } 194 | post{ 195 | always{ 196 | qyWechatNotification failNotify: true, webhookUrl: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=c79e3215-d39f-44a7-a760-fa0ab23ca46b' 197 | } 198 | } 199 | } 200 | ``` 201 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------