├── Errata.txt ├── LICENSE.txt ├── README.md ├── contributing.md └── source-code-kubernetes ├── chapter10 ├── mysql.yaml └── pod-reserve-resource.yaml ├── chapter11 ├── cert.yaml ├── hello-world.yaml ├── mysql-2.yaml ├── mysql.yaml └── pod.yaml ├── chapter12 ├── compute-resource-quotas.yaml ├── mysql.yaml └── object-quotas.yaml ├── chapter14 ├── counter-pod.yaml ├── es-controller.yaml ├── es-service.yaml ├── fluentd-es.yaml ├── fluentd-service.yaml ├── kibana-rc.yaml ├── kibana-service.yaml └── mysql-rc.yaml ├── chapter15 ├── ansible.cfg ├── hosts.txt └── install-network-manager.txt ├── chapter4 ├── claim1.json ├── pod.yaml └── subnets.txt ├── chapter6 ├── mysql-rc.yaml ├── pod-aws.yaml └── pod.yaml ├── chapter8 ├── best-effort-quotas.yaml ├── mysql-2.yaml ├── mysql-3.yaml ├── mysql-deployment.yaml └── mysql.yaml └── chapter9 ├── pod-helloworld.yaml ├── pod-nginx.yaml ├── pod-node-affinity.yaml ├── pod.yaml ├── pod1.yaml ├── pod2.yaml └── podNodeAffinity.yaml /Errata.txt: -------------------------------------------------------------------------------- 1 | Chapter 9 2 | 3 | 4 | Figure 9-21 is for the listing pod-helloworld.yaml and should be listed subsequent to the listing pod-helloworld.yaml. -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/kubernetes-mgmt-design-patterns/a35fc6c1896f27599b66dd99ab98cae18928a0b2/LICENSE.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Apress Source Code 2 | 3 | This repository accompanies [*Kubernetes Management Design Patterns*](http://www.apress.com/9781484225974) by Deepak Vohra (Apress, 2017). 4 | 5 | [comment]: #cover 6 | 7 | Download the files as a zip using the green button, or clone the repository to your machine using Git. 8 | 9 | ## Releases 10 | 11 | Release v1.0 corresponds to the code in the published book, without corrections or updates. 12 | 13 | ## Contributions 14 | 15 | See the file Contributing.md for more information on how you can contribute to this repository. 16 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to Apress Source Code 2 | 3 | Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. 4 | 5 | ## How to Contribute 6 | 7 | 1. Make sure you have a GitHub account. 8 | 2. Fork the repository for the relevant book. 9 | 3. Create a new branch on which to make your change, e.g. 10 | `git checkout -b my_code_contribution` 11 | 4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. 12 | 5. Submit a pull request. 13 | 14 | Thank you for your contribution! -------------------------------------------------------------------------------- /source-code-kubernetes/chapter10/mysql.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ReplicationController 4 | metadata: 5 | name: mysql-v1 6 | labels: 7 | app: mysql-app 8 | spec: 9 | replicas: 3 10 | selector: 11 | app: mysql-app 12 | deployment: v1 13 | template: 14 | metadata: 15 | labels: 16 | app: mysql-app 17 | deployment: v1 18 | spec: 19 | containers: 20 | - 21 | env: 22 | - 23 | name: MYSQL_ROOT_PASSWORD 24 | value: mysql 25 | image: mysql 26 | name: mysql 27 | ports: 28 | - 29 | containerPort: 3306 30 | resources: 31 | requests: 32 | memory: "64Mi" 33 | cpu: "250m" 34 | limits: 35 | memory: "128Mi" 36 | cpu: "500m" 37 | 38 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter10/pod-reserve-resource.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/kubernetes-mgmt-design-patterns/a35fc6c1896f27599b66dd99ab98cae18928a0b2/source-code-kubernetes/chapter10/pod-reserve-resource.yaml -------------------------------------------------------------------------------- /source-code-kubernetes/chapter11/cert.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: nginx-cert 5 | data: 6 | cert.pem: |- 7 | -----BEGIN CERTIFICATE----- 8 | abc 9 | -----END CERTIFICATE----- 10 | privkey.pem: |- 11 | -----BEGIN PRIVATE KEY----- 12 | abc 13 | -----END PRIVATE KEY----- 14 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter11/hello-world.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | labels: 6 | app: helloApp 7 | name: hello-world 8 | spec: 9 | containers: 10 | - 11 | args: 12 | - " $(MESSAGE1)" 13 | - " $(MESSAGE2)" 14 | command: 15 | - /bin/echo 16 | env: 17 | - 18 | name: MESSAGE1 19 | valueFrom: 20 | configMapKeyRef: 21 | key: message1 22 | name: hello-config 23 | - 24 | name: MESSAGE2 25 | valueFrom: 26 | configMapKeyRef: 27 | key: message2 28 | name: hello-config 29 | image: ubuntu 30 | name: hello 31 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter11/mysql-2.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ReplicationController 4 | metadata: 5 | labels: 6 | app: mysql-app 7 | name: mysql 8 | spec: 9 | replicas: 3 10 | selector: 11 | app: mysql-app 12 | template: 13 | metadata: 14 | labels: 15 | app: mysql-app 16 | spec: 17 | containers: 18 | - 19 | env: 20 | - 21 | name: MYSQL_ROOT_PASSWORD 22 | valueFrom: 23 | configMapKeyRef: 24 | key: mysql.root.password 25 | name: mysql-config-2 26 | 27 | - 28 | name: MYSQL_ALLOW_EMPTY_PASSWORD 29 | valueFrom: 30 | configMapKeyRef: 31 | key: mysql.allow.empty.password 32 | name: mysql-config-2 33 | image: mysql 34 | name: mysql 35 | ports: 36 | - 37 | containerPort: 3306 38 | 39 | 40 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter11/mysql.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ReplicationController 4 | metadata: 5 | labels: 6 | app: mysql-app 7 | name: mysql 8 | spec: 9 | replicas: 3 10 | selector: 11 | app: mysql-app 12 | template: 13 | metadata: 14 | labels: 15 | app: mysql-app 16 | spec: 17 | containers: 18 | - 19 | env: 20 | - 21 | name: MYSQL_ROOT_PASSWORD 22 | valueFrom: 23 | configMapKeyRef: 24 | key: mysql.root.password 25 | name: mysql-config 26 | - 27 | name: MYSQL_DATABASE 28 | valueFrom: 29 | configMapKeyRef: 30 | key: mysql.database 31 | name: mysql-config 32 | - 33 | name: MYSQL_USER 34 | valueFrom: 35 | configMapKeyRef: 36 | key: mysql.user 37 | name: mysql-config 38 | - 39 | name: MYSQL_PASSWORD 40 | valueFrom: 41 | configMapKeyRef: 42 | key: mysql.user 43 | name: mysql-config 44 | - 45 | name: MYSQL_ALLOW_EMPTY_PASSWORD 46 | valueFrom: 47 | configMapKeyRef: 48 | key: mysql.allow.empty.password 49 | name: mysql-config 50 | image: mysql 51 | name: mysql 52 | ports: 53 | - 54 | containerPort: 3306 55 | 56 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter11/pod.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | name: configmap-volume 6 | spec: 7 | containers: 8 | - 9 | image: nginx 10 | name: nginx 11 | volumeMounts: 12 | - 13 | mountPath: /etc/config/cert 14 | name: config-volume 15 | readOnly: true 16 | volumes: 17 | - 18 | configMap: 19 | name: nginx-cert 20 | name: config-volume 21 | 22 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter12/compute-resource-quotas.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ResourceQuota 3 | metadata: 4 | name: compute-resource-quotas 5 | spec: 6 | hard: 7 | pods: "10" 8 | requests.cpu: "1" 9 | requests.memory: 2Gi 10 | limits.cpu: "2" 11 | limits.memory: 4Gi 12 | scopes: 13 | - 14 | NotBestEffort 15 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter12/mysql.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ReplicationController 4 | metadata: 5 | name: mysql-rc 6 | labels: 7 | app: mysql-app 8 | spec: 9 | replicas: 3 10 | selector: 11 | app: mysql-app 12 | deployment: v1 13 | template: 14 | metadata: 15 | labels: 16 | app: mysql-app 17 | deployment: v1 18 | spec: 19 | containers: 20 | - 21 | env: 22 | - 23 | name: MYSQL_ROOT_PASSWORD 24 | value: mysql 25 | image: mysql 26 | name: mysql 27 | ports: 28 | - 29 | containerPort: 3306 30 | resources: 31 | requests: 32 | memory: "640Mi" 33 | cpu: "500m" 34 | limits: 35 | memory: "1280Mi" 36 | cpu: "2" 37 | 38 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter12/object-quotas.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ResourceQuota 3 | metadata: 4 | name: object-quotas 5 | spec: 6 | hard: 7 | configmaps: "5" 8 | replicationcontrollers: "1" 9 | services: "2" 10 | 11 | 12 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter14/counter-pod.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | name: counter 6 | spec: 7 | containers: 8 | - 9 | args: 10 | - bash 11 | - "-c" 12 | - "for ((i = 0; ; i++)); do echo \"$i: $(date)\"; sleep 1; done" 13 | image: "ubuntu:14.04" 14 | name: count 15 | 16 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter14/es-controller.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ReplicationController 4 | metadata: 5 | labels: 6 | k8s-app: elasticsearch-logging 7 | kubernetes.io/cluster-service: "true" 8 | version: v1 9 | name: elasticsearch-logging-v1 10 | namespace: kube-system 11 | spec: 12 | replicas: 2 13 | selector: 14 | k8s-app: elasticsearch-logging 15 | version: v1 16 | template: 17 | metadata: 18 | labels: 19 | k8s-app: elasticsearch-logging 20 | kubernetes.io/cluster-service: "true" 21 | version: v1 22 | spec: 23 | containers: 24 | - 25 | image: "gcr.io/google_containers/elasticsearch:1.9" 26 | name: elasticsearch-logging 27 | ports: 28 | - 29 | containerPort: 9200 30 | name: db 31 | protocol: TCP 32 | - 33 | containerPort: 9300 34 | name: transport 35 | protocol: TCP 36 | resources: 37 | limits: 38 | cpu: "0.1" 39 | requests: 40 | cpu: "0.1" 41 | volumeMounts: 42 | - 43 | mountPath: /data 44 | name: es-persistent-storage 45 | volumes: 46 | - 47 | emptyDir: {} 48 | name: es-persistent-storage 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter14/es-service.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | labels: 6 | k8s-app: elasticsearch-logging 7 | kubernetes.io/cluster-service: "true" 8 | kubernetes.io/name: Elasticsearch 9 | name: elasticsearch-logging 10 | namespace: kube-system 11 | spec: 12 | ports: 13 | - 14 | port: 9200 15 | protocol: TCP 16 | targetPort: db 17 | selector: 18 | k8s-app: elasticsearch-logging 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter14/fluentd-es.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | name: fluentd-elasticsearch 6 | spec: 7 | containers: 8 | - 9 | env: 10 | - 11 | name: ELASTICSEARCH_HOST 12 | value: "10.2.15.2" 13 | - 14 | name: ELASTICSEARCH_PORT 15 | value: "9200" 16 | image: "fabric8/fluentd-kubernetes:v1.9" 17 | name: fluentd-elasticsearch 18 | resources: 19 | limits: 20 | cpu: "0.1" 21 | securityContext: 22 | privileged: true 23 | volumeMounts: 24 | - 25 | mountPath: /var/log 26 | name: varlog 27 | - 28 | mountPath: /var/lib/docker/containers 29 | name: varlibdockercontainers 30 | readOnly: true 31 | volumes: 32 | - 33 | hostPath: 34 | path: /var/log 35 | name: varlog 36 | - 37 | hostPath: 38 | path: /var/lib/docker/containers 39 | name: varlibdockercontainers 40 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter14/fluentd-service.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | labels: 6 | k8s-app: elasticsearch-logging 7 | kubernetes.io/cluster-service: "true" 8 | kubernetes.io/name: Kibana 9 | name: kibana-logging 10 | namespace: kube-system 11 | spec: 12 | ports: 13 | - 14 | port: 5601 15 | protocol: TCP 16 | selector: 17 | k8s-app: kibana-logging 18 | 19 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter14/kibana-rc.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ReplicationController 4 | metadata: 5 | labels: 6 | k8s-app: kibana-logging 7 | kubernetes.io/cluster-service: "true" 8 | version: v1 9 | name: kibana-logging-v1 10 | namespace: kube-system 11 | spec: 12 | replicas: 1 13 | selector: 14 | k8s-app: kibana-logging 15 | version: v1 16 | template: 17 | metadata: 18 | labels: 19 | k8s-app: kibana-logging 20 | kubernetes.io/cluster-service: "true" 21 | version: v1 22 | spec: 23 | containers: 24 | - 25 | env: 26 | - 27 | name: ELASTICSEARCH_URL 28 | value: "http://10.2.15.2:9200" 29 | image: "gcr.io/google_containers/kibana:1.3" 30 | name: kibana-logging 31 | ports: 32 | - 33 | containerPort: 5601 34 | name: ui 35 | protocol: TCP 36 | resources: 37 | limits: 38 | cpu: "0.1" 39 | requests: 40 | cpu: "0.1" 41 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter14/kibana-service.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | labels: 6 | k8s-app: elasticsearch-logging 7 | kubernetes.io/cluster-service: "true" 8 | kubernetes.io/name: Kibana 9 | name: kibana-logging 10 | namespace: kube-system 11 | spec: 12 | ports: 13 | - 14 | port: 5601 15 | protocol: TCP 16 | selector: 17 | k8s-app: kibana-logging 18 | 19 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter14/mysql-rc.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ReplicationController 4 | metadata: 5 | labels: 6 | app: mysqlapp 7 | name: mysql-rc 8 | namespace: kube-system 9 | spec: 10 | replicas: 3 11 | selector: 12 | app: mysqlapp 13 | template: 14 | metadata: 15 | labels: 16 | app: mysqlapp 17 | spec: 18 | containers: 19 | - 20 | env: 21 | - 22 | name: MYSQL_ROOT_PASSWORD 23 | value: mysql 24 | image: mysql 25 | name: mysql 26 | ports: 27 | - 28 | containerPort: 3306 29 | 30 | 31 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter15/ansible.cfg: -------------------------------------------------------------------------------- 1 | sudo= yes 2 | ask_sudo_pass=False 3 | ask_pass=False 4 | remote_user = centos 5 | host_key_checking = False 6 | timeout=0 7 | private_key_file= ~/docker.pem 8 | 9 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter15/hosts.txt: -------------------------------------------------------------------------------- 1 | [OSEv3:children] 2 | masters 3 | etcd 4 | lb 5 | nodes 6 | Next, specify some variables 7 | [OSEv3:vars] 8 | ansible_user=centos 9 | ansible_sudo=true 10 | deployment_type=origin 11 | ansible_ssh_private_key_file=~/docker.pem 12 | 13 | [masters] 14 | ec2-54-90-107-98.compute-1.amazonaws.com openshift_ip=10.156.14.183 openshift_public_ip=54.90.107.98 openshift_hostname=ip-10-156-14-183.ec2.internal openshift_public_hostname=ec2-54-90-107-98.compute-1.amazonaws.com 15 | ec2-54-221-182-68.compute-1.amazonaws.com openshift_ip=10.154.46.153 openshift_public_ip=54.221.182.68 openshift_hostname=ip-10-154-46-153.ec2.internal openshift_public_hostname=ec2-54-221-182-68.compute-1.amazonaws.com 16 | 17 | [etcd] 18 | ec2-54-160-210-253.compute-1.amazonaws.com openshift_ip=10.153.195.121 openshift_public_ip=54.160.210.253 openshift_hostname=ip-10-153-195-121.ec2.internal openshift_public_hostname=ec2-54-160-210-253.compute-1.amazonaws.com 19 | 20 | [lb] 21 | ec2-54-226-7-241.compute-1.amazonaws.com openshift_ip=10.154.38.224 openshift_public_ip=54.226.7.241 openshift_hostname=ip-10-154-38-224.ec2.internal openshift_public_hostname=ec2-54-226-7-241.compute-1.amazonaws.com 22 | 23 | [nodes] 24 | ec2-54-90-107-98.compute-1.amazonaws.com openshift_ip=10.156.14.183 openshift_public_ip=54.90.107.98 openshift_hostname=ip-10-156-14-183.ec2.internal openshift_public_hostname=ec2-54-90-107-98.compute-1.amazonaws.com openshift_node_labels="{'region': 'primary', 'zone': 'east'}" openshift_schedulable=false 25 | ec2-54-221-182-68.compute-1.amazonaws.com openshift_ip=10.154.46.153 openshift_public_ip=54.221.182.68 openshift_hostname=ip-10-154-46-153.ec2.internal openshift_public_hostname=ec2-54-221-182-68.compute-1.amazonaws.com openshift_node_labels="{'region': 'primary', 'zone': 'east'}" openshift_schedulable=false 26 | ec2-54-159-26-13.compute-1.amazonaws.com openshift_ip=10.113.176.99 openshift_public_ip=54.159.26.13 openshift_hostname=ip-10-113-176-99.ec2.internal openshift_public_hostname=ec2-54-159-26-13.compute-1.amazonaws.com openshift_node_labels="{'region': 'primary', 'zone': 'east'}" 27 | 28 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter15/install-network-manager.txt: -------------------------------------------------------------------------------- 1 | sudo yum install NetworkManager 2 | sudo systemctl start NetworkManager 3 | sudo systemctl enable NetworkManager 4 | sudo systemctl status NetworkManager 5 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter4/claim1.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "PersistentVolumeClaim", 3 | "apiVersion": "v1", 4 | "metadata": { 5 | "name": "claim1", 6 | "annotations": { 7 | "volume.alpha.kubernetes.io/storage-class": "foo" 8 | } 9 | }, 10 | "spec": { 11 | "accessModes": [ 12 | "ReadWriteOnce" 13 | ], 14 | "resources": { 15 | "requests": { 16 | "storage": "3Gi" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter4/pod.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | name: nginx 6 | spec: 7 | containers: 8 | - 9 | image: nginx 10 | name: nginx 11 | volumeMounts: 12 | - 13 | mountPath: /var/www/html 14 | name: pv 15 | volumes: 16 | - 17 | name: pv 18 | persistentVolumeClaim: 19 | claimName: claim1 20 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter4/subnets.txt: -------------------------------------------------------------------------------- 1 | subnets: 2 | - 3 | availabilityZone: us-east-1b 4 | instanceCIDR: "10.0.0.0/24" 5 | - 6 | availabilityZone: us-east-1c 7 | instanceCIDR: "10.0.0.0/24" 8 | - 9 | availabilityZone: us-east-1d 10 | instanceCIDR: "10.0.0.0/24" 11 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter6/mysql-rc.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ReplicationController 4 | metadata: 5 | name: mysql-rc 6 | labels: 7 | app: mysql-app 8 | spec: 9 | replicas: 3 10 | selector: 11 | app: mysql-app 12 | deployment: v1 13 | template: 14 | metadata: 15 | labels: 16 | app: mysql-app 17 | deployment: v1 18 | spec: 19 | containers: 20 | - 21 | env: 22 | - 23 | name: MYSQL_ROOT_PASSWORD 24 | value: mysql 25 | image: mysql 26 | name: mysql 27 | ports: 28 | - 29 | containerPort: 3306 30 | resources: 31 | requests: 32 | memory: "64Mi" 33 | cpu: "0.1" 34 | limits: 35 | memory: "128Mi" 36 | cpu: "0.2" 37 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter6/pod-aws.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ReplicationController 4 | metadata: 5 | labels: 6 | app: nginx 7 | name: nginx-rc 8 | spec: 9 | replicas: 1 10 | template: 11 | metadata: 12 | labels: 13 | app: nginx 14 | spec: 15 | containers: 16 | - 17 | image: nginx 18 | name: nginx 19 | volumeMounts: 20 | - 21 | mountPath: /aws-ebs 22 | name: aws-volume 23 | volumes: 24 | - 25 | awsElasticBlockStore: 26 | fsType: ext4 27 | volumeID: "aws://us-east-1c/vol-62a59dc8" 28 | name: aws-volume 29 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter6/pod.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | name: server 6 | spec: 7 | containers: 8 | - 9 | image: nginx 10 | name: nginx 11 | volumeMounts: 12 | - 13 | mountPath: /git-repo 14 | name: git-volume 15 | volumes: 16 | - 17 | gitRepo: 18 | repository: "" 19 | revision: "" 20 | name: git-volume 21 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter8/best-effort-quotas.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ResourceQuota 3 | metadata: 4 | name: best-effort-quotas 5 | spec: 6 | hard: 7 | pods: "5" 8 | scopes: 9 | - 10 | BestEffort 11 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter8/mysql-2.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ReplicationController 4 | metadata: 5 | name: mysql-v1 6 | labels: 7 | app: mysql-app 8 | spec: 9 | replicas: 3 10 | selector: 11 | app: mysql-app 12 | deployment: v2 13 | template: 14 | metadata: 15 | labels: 16 | app: mysql-app 17 | deployment: v2 18 | spec: 19 | containers: 20 | - 21 | env: 22 | - 23 | name: MYSQL_ROOT_PASSWORD 24 | value: mysql 25 | image: mysql:5.5 26 | name: mysql 27 | ports: 28 | - 29 | containerPort: 3306 30 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter8/mysql-3.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ReplicationController 4 | metadata: 5 | name: mysql-v1 6 | labels: 7 | app: mysql-app 8 | spec: 9 | replicas: 3 10 | selector: 11 | app: mysql-app 12 | deployment: v1 13 | template: 14 | metadata: 15 | labels: 16 | app: mysql-app 17 | deployment: v1 18 | spec: 19 | containers: 20 | - 21 | env: 22 | - 23 | name: MYSQL_ROOT_PASSWORD 24 | value: mysql 25 | image: mysql:5.5 26 | name: mysql 27 | ports: 28 | - 29 | containerPort: 3306 30 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter8/mysql-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: mysql-deployment 5 | spec: 6 | replicas: 5 7 | template: 8 | metadata: 9 | labels: 10 | app: mysql 11 | spec: 12 | containers: 13 | - name: mysql 14 | image: mysql:5.5 15 | ports: 16 | - containerPort: 80 17 | strategy: 18 | type: RollingUpdate 19 | rollingUpdate: 20 | maxUnavailable: 75% 21 | maxSurge: 30% 22 | rollbackTo: 23 | revision: 0 24 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter8/mysql.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ReplicationController 4 | metadata: 5 | name: mysql 6 | labels: 7 | app: mysql-app 8 | spec: 9 | replicas: 3 10 | selector: 11 | app: mysql-app 12 | deployment: v1 13 | template: 14 | metadata: 15 | labels: 16 | app: mysql-app 17 | deployment: v1 18 | spec: 19 | containers: 20 | - 21 | env: 22 | - 23 | name: MYSQL_ROOT_PASSWORD 24 | value: mysql 25 | image: mysql 26 | name: mysql 27 | ports: 28 | - 29 | containerPort: 3306 30 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter9/pod-helloworld.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: hello-world 5 | labels: 6 | env: test 7 | spec: 8 | containers: 9 | - name: hello-world 10 | image: hello-world 11 | imagePullPolicy: IfNotPresent 12 | nodeSelector: 13 | kubernetes.io/image-name: hello-world 14 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter9/pod-nginx.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: nginx 5 | labels: 6 | env: test 7 | spec: 8 | containers: 9 | - name: nginx 10 | image: nginx 11 | imagePullPolicy: IfNotPresent 12 | nodeSelector: 13 | kubernetes.io/image-name: nginx 14 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter9/pod-node-affinity.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: with-labels 5 | annotations: 6 | scheduler.alpha.kubernetes.io/affinity: > 7 | { 8 | "nodeAffinity": { 9 | "requiredDuringSchedulingIgnoredDuringExecution": { 10 | "nodeSelectorTerms": [ 11 | { 12 | "matchExpressions": [ 13 | { 14 | "key": "kubernetes.io/image-name", 15 | "operator": "In", 16 | "values": ["nginx2", "hello-world2"] 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | } 23 | } 24 | kubernetes.io/image-name: nginx 25 | spec: 26 | containers: 27 | - name: with-labels 28 | image: nginx 29 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter9/pod.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: nginx 5 | labels: 6 | env: test 7 | spec: 8 | containers: 9 | - name: nginx 10 | image: nginx 11 | imagePullPolicy: IfNotPresent 12 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter9/pod1.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | name: pod-without-annotation 6 | labels: 7 | name: multischeduler 8 | spec: 9 | containers: 10 | - 11 | image: "gcr.io/google_containers/pause:2.0" 12 | name: pod-without-annotation 13 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter9/pod2.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | annotations: 6 | scheduler.alpha.kubernetes.io/name: default-scheduler 7 | labels: 8 | name: multischeduler 9 | name: default-scheduler 10 | spec: 11 | containers: 12 | - 13 | image: "gcr.io/google_containers/pause:2.0" 14 | name: pod-with-default-scheduler-annotation-container 15 | -------------------------------------------------------------------------------- /source-code-kubernetes/chapter9/podNodeAffinity.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: with-labels 5 | annotations: 6 | scheduler.alpha.kubernetes.io/affinity: > 7 | { 8 | "nodeAffinity": { 9 | "preferredDuringSchedulingIgnoredDuringExecution": [ 10 | { 11 | "weight": 75, 12 | "preference": 13 | { 14 | "matchExpressions": [ 15 | { 16 | "key": "kubernetes.io/image-name", 17 | "operator": "In", 18 | "values": ["nginx", "hello-world"] 19 | } 20 | ] 21 | } 22 | } 23 | ] 24 | } 25 | } 26 | kubernetes.io/image-name: hello-world 27 | spec: 28 | containers: 29 | - name: with-labels 30 | image: nginx 31 | 32 | --------------------------------------------------------------------------------