diff --git a/CH06/Listing0601-Using a Volume in a Pod Spec (volume.yaml).txt b/CH06/Listing0601-Using a Volume in a Pod Spec (volume.yaml).txt new file mode 100644 index 0000000..8aa7c3c --- /dev/null +++ b/CH06/Listing0601-Using a Volume in a Pod Spec (volume.yaml).txt @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Pod +metadata: + name: nginx-pod +spec: + containers: + - name: nginx + image: nginx + ports: + - containerPort: 80 + volumeMounts: + - name: webcontent + mountPath: "/usr/share/nginx/html/web-app" + volumes: + - name: webcontent + nfs: + server: 172.16.94.5 + path: "/srv/exports/volumes/webcontent" \ No newline at end of file diff --git a/CH06/Listing0602-Example Persistent Volume (pv.yaml).txt b/CH06/Listing0602-Example Persistent Volume (pv.yaml).txt new file mode 100644 index 0000000..9869f09 --- /dev/null +++ b/CH06/Listing0602-Example Persistent Volume (pv.yaml).txt @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: pv-nfs-data-static +spec: + capacity: + storage: 10Gi + accessModes: + - ReadWriteMany + nfs: + server: 172.16.94.5 + path: "/srv/exports/volumes/webcontent" \ No newline at end of file diff --git a/CH06/Listing0603-Example Persistent Volume Claim (pvc.yaml).txt b/CH06/Listing0603-Example Persistent Volume Claim (pvc.yaml).txt new file mode 100644 index 0000000..4a3f9d8 --- /dev/null +++ b/CH06/Listing0603-Example Persistent Volume Claim (pvc.yaml).txt @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pvc-nfs-data-static +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 10Gi \ No newline at end of file diff --git a/CH06/Listing0604-A Deployment using Persistent Storage (deployment-static.yaml).txt b/CH06/Listing0604-A Deployment using Persistent Storage (deployment-static.yaml).txt new file mode 100644 index 0000000..30e85b7 --- /dev/null +++ b/CH06/Listing0604-A Deployment using Persistent Storage (deployment-static.yaml).txt @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-nfs-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + volumes: + - name: webcontent + persistentVolumeClaim: + claimName: pvc-nfs-data-static + containers: + - name: nginx + image: nginx + ports: + - containerPort: 80 + volumeMounts: + - name: webcontent + mountPath: "/usr/share/nginx/html/web-app" +--- +apiVersion: v1 +kind: Service +metadata: + name: nginx-nfs-service +spec: + selector: + app: nginx + ports: + - port: 80 + protocol: TCP + targetPort: 80 \ No newline at end of file diff --git a/CH06/Listing0605-nfs-rbac.yaml.txt b/CH06/Listing0605-nfs-rbac.yaml.txt new file mode 100644 index 0000000..07349af --- /dev/null +++ b/CH06/Listing0605-nfs-rbac.yaml.txt @@ -0,0 +1,57 @@ +kind: ServiceAccount +apiVersion: v1 +metadata: + name: nfs-client-provisioner +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: nfs-client-provisioner-runner +rules: + - apiGroups: [""] + resources: ["persistentvolumes"] + verbs: ["get", "list", "watch", "create", "delete"] + - apiGroups: [""] + resources: ["persistentvolumeclaims"] + verbs: ["get", "list", "watch", "update"] + - apiGroups: ["storage.k8s.io"] + resources: ["storageclasses"] + verbs: ["get", "list", "watch"] + - apiGroups: [""] + resources: ["events"] + verbs: ["create", "update", "patch"] +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: run-nfs-client-provisioner +subjects: + - kind: ServiceAccount + name: nfs-client-provisioner + namespace: default +roleRef: + kind: ClusterRole + name: nfs-client-provisioner-runner + apiGroup: rbac.authorization.k8s.io +--- +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: leader-locking-nfs-client-provisioner +rules: + - apiGroups: [""] + resources: ["endpoints"] + verbs: ["get", "list", "watch", "create", "update", "patch"] +--- +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: leader-locking-nfs-client-provisioner +subjects: + - kind: ServiceAccount + name: nfs-client-provisioner + namespace: default +roleRef: + kind: Role + name: leader-locking-nfs-client-provisioner + apiGroup: rbac.authorization.k8s.io \ No newline at end of file diff --git a/CH06/Listing0606-nfs-storageclass.yaml.txt b/CH06/Listing0606-nfs-storageclass.yaml.txt new file mode 100644 index 0000000..65e68ca --- /dev/null +++ b/CH06/Listing0606-nfs-storageclass.yaml.txt @@ -0,0 +1,7 @@ +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: nfs-storage +provisioner: example.com/nfs +parameters: + archiveOnDelete: "false" \ No newline at end of file diff --git a/CH06/Listing0607-API Server section in kube-apiserver.yaml.txt b/CH06/Listing0607-API Server section in kube-apiserver.yaml.txt new file mode 100644 index 0000000..1f029a1 --- /dev/null +++ b/CH06/Listing0607-API Server section in kube-apiserver.yaml.txt @@ -0,0 +1,4 @@ +spec: + containers: + - command: + - kube-apiserver \ No newline at end of file diff --git a/CH06/Listing0608-New line in kube-apiserver.yaml.txt b/CH06/Listing0608-New line in kube-apiserver.yaml.txt new file mode 100644 index 0000000..13f5c09 --- /dev/null +++ b/CH06/Listing0608-New line in kube-apiserver.yaml.txt @@ -0,0 +1 @@ +- --feature-gates=RemoveSelfLink=false \ No newline at end of file diff --git a/CH06/Listing0609-nfs-provisioner.yaml.txt b/CH06/Listing0609-nfs-provisioner.yaml.txt new file mode 100644 index 0000000..4772347 --- /dev/null +++ b/CH06/Listing0609-nfs-provisioner.yaml.txt @@ -0,0 +1,35 @@ +kind: Deployment +apiVersion: apps/v1 +metadata: + name: nfs-client-provisioner +spec: + selector: + matchLabels: + app: nfs-client-provisioner + replicas: 1 + strategy: + type: Recreate + template: + metadata: + labels: + app: nfs-client-provisioner + spec: + serviceAccountName: nfs-client-provisioner + containers: + - name: nfs-client-provisioner + image: quay.io/external_storage/nfs-client-provisioner:latest + volumeMounts: + - name: nfs-client-root + mountPath: /persistentvolumes + env: + - name: PROVISIONER_NAME + value: example.com/nfs + - name: NFS_SERVER + value: 172.16.94.5 + - name: NFS_PATH + value: /srv/exports/volumes + volumes: + - name: nfs-client-root + nfs: + server: 172.16.94.5 + path: /srv/exports/volumes \ No newline at end of file diff --git a/CH06/Listing0610-A Deployment using dynamic provisioning (deployment-dynamic.yaml).txt b/CH06/Listing0610-A Deployment using dynamic provisioning (deployment-dynamic.yaml).txt new file mode 100644 index 0000000..f7a3bcd --- /dev/null +++ b/CH06/Listing0610-A Deployment using dynamic provisioning (deployment-dynamic.yaml).txt @@ -0,0 +1,50 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pvc-nfs-data-dynamic +spec: + accessModes: + - ReadWriteOnce + storageClassName: nfs-storage + resources: + requests: + storage: 10Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-nfs-deployment-dynamic +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx + ports: + - containerPort: 80 + volumeMounts: + - name: webcontent + mountPath: "/usr/share/nginx/html/web-app" + volumes: + - name: webcontent + persistentVolumeClaim: + claimName: pvc-nfs-data-dynamic +--- +apiVersion: v1 +kind: Service +metadata: + name: nginx-nfs-service-dynamic +spec: + selector: + app: nginx + ports: + - port: 80 + protocol: TCP + targetPort: 80 \ No newline at end of file diff --git a/CH06/Listing0611-A deployment using a Persistent Volume Claim and dynamic provisioning of Azure storage (deployment-dynamic-azure.yaml).txt b/CH06/Listing0611-A deployment using a Persistent Volume Claim and dynamic provisioning of Azure storage (deployment-dynamic-azure.yaml).txt new file mode 100644 index 0000000..e28f55f --- /dev/null +++ b/CH06/Listing0611-A deployment using a Persistent Volume Claim and dynamic provisioning of Azure storage (deployment-dynamic-azure.yaml).txt @@ -0,0 +1,51 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pvc-azure-data-dynamic +spec: + accessModes: + - ReadWriteOnce + storageClassName: managed-premium + resources: + requests: + storage: 10Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-azure-deployment-dynamic +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx + ports: + - containerPort: 80 + volumeMounts: + - name: webcontent + mountPath: "/usr/share/nginx/html/web-app" + volumes: + - name: webcontent + persistentVolumeClaim: + claimName: pvc-azure-data-dynamic +--- +apiVersion: v1 +kind: Service +metadata: + name: nginx-azure-service-dynamic +spec: + selector: + app: nginx + ports: + - port: 80 + protocol: TCP + targetPort: 80 + type: LoadBalancer \ No newline at end of file diff --git a/CH07/Listing0701-sql-storage.yaml.txt b/CH07/Listing0701-sql-storage.yaml.txt new file mode 100644 index 0000000..450817f --- /dev/null +++ b/CH07/Listing0701-sql-storage.yaml.txt @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: pv-nfs-sql-instance-1 + labels: + disk: system +spec: + capacity: + storage: 10Gi + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + nfs: + server: storage + path: "/srv/exports/volumes/sql-instance-1" +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pvc-nfs-sql-instance-1 +spec: + selector: + matchLabels: + disk: system + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi \ No newline at end of file diff --git a/CH07/Listing0702-Apply sql-storage.yaml to Kubernetes cluster.txt b/CH07/Listing0702-Apply sql-storage.yaml to Kubernetes cluster.txt new file mode 100644 index 0000000..40ad708 --- /dev/null +++ b/CH07/Listing0702-Apply sql-storage.yaml to Kubernetes cluster.txt @@ -0,0 +1 @@ +kubectl apply -f sql-storage.yaml \ No newline at end of file diff --git a/CH07/Listing0703-Verify previously created PV and PVC.txt b/CH07/Listing0703-Verify previously created PV and PVC.txt new file mode 100644 index 0000000..28cbbae --- /dev/null +++ b/CH07/Listing0703-Verify previously created PV and PVC.txt @@ -0,0 +1,2 @@ +kubectl get pv +kubectl get pvc diff --git a/CH07/Listing0704-Create Kubernetes Secret using kubectl.txt b/CH07/Listing0704-Create Kubernetes Secret using kubectl.txt new file mode 100644 index 0000000..f611e47 --- /dev/null +++ b/CH07/Listing0704-Create Kubernetes Secret using kubectl.txt @@ -0,0 +1 @@ +kubectl create secret generic mssql --from-literal=SA_PASSWORD=S0methingS@Str0ng! \ No newline at end of file diff --git a/CH07/Listing0705-sql-deployment.yaml.txt b/CH07/Listing0705-sql-deployment.yaml.txt new file mode 100644 index 0000000..d68dde7 --- /dev/null +++ b/CH07/Listing0705-sql-deployment.yaml.txt @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mssql-deployment +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: mssql + template: + metadata: + labels: + app: mssql + spec: + securityContext: + fsGroup: 10001 + containers: + - name: mssql + image: 'mcr.microsoft.com/mssql/server:2019-CU8-ubuntu-18.04' + ports: + - containerPort: 1433 + env: + - name: ACCEPT_EULA + value: "Y" + - name: SA_PASSWORD + valueFrom: + secretKeyRef: + name: mssql + key: SA_PASSWORD + volumeMounts: + - name: mssqldb + mountPath: /var/opt/mssql + volumes: + - name: mssqldb + persistentVolumeClaim: + claimName: pvc-nfs-sql-instance-1 +--- +apiVersion: v1 +kind: Service +metadata: + name: mssql-deployment +spec: + selector: + app: mssql + ports: + - protocol: TCP + port: 31433 + targetPort: 1433 + type: NodePort diff --git a/CH07/Listing0706-Apply sql-deployment.yaml to Kubernetes cluster.txt b/CH07/Listing0706-Apply sql-deployment.yaml to Kubernetes cluster.txt new file mode 100644 index 0000000..a642ce2 --- /dev/null +++ b/CH07/Listing0706-Apply sql-deployment.yaml to Kubernetes cluster.txt @@ -0,0 +1 @@ +kubectl apply -f sql-deployment.yaml \ No newline at end of file diff --git a/CH07/Listing0707-Check status of deployment.txt b/CH07/Listing0707-Check status of deployment.txt new file mode 100644 index 0000000..1533edf --- /dev/null +++ b/CH07/Listing0707-Check status of deployment.txt @@ -0,0 +1 @@ +kubectl get deployment \ No newline at end of file diff --git a/CH07/Listing0708-Check status of pod and service.txt b/CH07/Listing0708-Check status of pod and service.txt new file mode 100644 index 0000000..fce6e2e --- /dev/null +++ b/CH07/Listing0708-Check status of pod and service.txt @@ -0,0 +1,2 @@ +kubectl get pods +kubectl get service diff --git a/CH07/Listing0709-sqlcmd query for Servername and Version.txt b/CH07/Listing0709-sqlcmd query for Servername and Version.txt new file mode 100644 index 0000000..389dbbc --- /dev/null +++ b/CH07/Listing0709-sqlcmd query for Servername and Version.txt @@ -0,0 +1 @@ +sqlcmd -S control, -U sa -P -Q "SELECT @@SERVERNAME,@@VERSION" \ No newline at end of file diff --git a/CH07/Listing0710-sqlcmd command to create a new user database.txt b/CH07/Listing0710-sqlcmd command to create a new user database.txt new file mode 100644 index 0000000..bc0bbef --- /dev/null +++ b/CH07/Listing0710-sqlcmd command to create a new user database.txt @@ -0,0 +1 @@ +sqlcmd -S control, -U sa -P -Q "CREATE DATABASE TestDB1" \ No newline at end of file diff --git a/CH07/Listing0711-List directory content of NFS share.txt b/CH07/Listing0711-List directory content of NFS share.txt new file mode 100644 index 0000000..d1642a5 --- /dev/null +++ b/CH07/Listing0711-List directory content of NFS share.txt @@ -0,0 +1 @@ +ls -al /srv/exports/volumes/sql-instance-1/* \ No newline at end of file diff --git a/CH07/Listing0712-Define a static hostname.txt b/CH07/Listing0712-Define a static hostname.txt new file mode 100644 index 0000000..26a9002 --- /dev/null +++ b/CH07/Listing0712-Define a static hostname.txt @@ -0,0 +1,5 @@ +spec: + securityContext: + fsGroup: 10001 + hostname: + sql01 diff --git a/CH07/Listing0713-Get pod name.txt b/CH07/Listing0713-Get pod name.txt new file mode 100644 index 0000000..7903f14 --- /dev/null +++ b/CH07/Listing0713-Get pod name.txt @@ -0,0 +1 @@ +kubectl get pods \ No newline at end of file diff --git a/CH07/Listing0714-Delete pod.txt b/CH07/Listing0714-Delete pod.txt new file mode 100644 index 0000000..710bb28 --- /dev/null +++ b/CH07/Listing0714-Delete pod.txt @@ -0,0 +1 @@ +kubectl delete pod mssql-deployment-748c745b8d-w2sf8 \ No newline at end of file diff --git a/CH07/Listing0715-List databases in our instance.txt b/CH07/Listing0715-List databases in our instance.txt new file mode 100644 index 0000000..50c3e10 --- /dev/null +++ b/CH07/Listing0715-List databases in our instance.txt @@ -0,0 +1 @@ +sqlcmd -S control, -U sa -P -Q "SELECT Name FROM sys.databases" \ No newline at end of file diff --git a/CH07/Listing0716-update image to CU9.txt b/CH07/Listing0716-update image to CU9.txt new file mode 100644 index 0000000..69fec96 --- /dev/null +++ b/CH07/Listing0716-update image to CU9.txt @@ -0,0 +1 @@ +kubectl set image deployment mssql-deployment mssql=mcr.microsoft.com/mssql/server:2019-CU9-ubuntu-18.04 \ No newline at end of file diff --git a/CH07/Listing0717-Describe deployment.txt b/CH07/Listing0717-Describe deployment.txt new file mode 100644 index 0000000..1bc50b5 --- /dev/null +++ b/CH07/Listing0717-Describe deployment.txt @@ -0,0 +1 @@ +kubectl describe deployment mssql-deployment \ No newline at end of file diff --git a/CH07/Listing0718-Retrieve history for second revision of a deployment.txt b/CH07/Listing0718-Retrieve history for second revision of a deployment.txt new file mode 100644 index 0000000..1332473 --- /dev/null +++ b/CH07/Listing0718-Retrieve history for second revision of a deployment.txt @@ -0,0 +1 @@ +kubectl rollout history deployment mssql-deployment --revision=2 \ No newline at end of file diff --git a/CH07/Listing0719-Resource section in YAML manifest.txt b/CH07/Listing0719-Resource section in YAML manifest.txt new file mode 100644 index 0000000..416f979 --- /dev/null +++ b/CH07/Listing0719-Resource section in YAML manifest.txt @@ -0,0 +1,10 @@ +spec: + containers: + - name: mssql + resources: + requests: + cpu: 1 + memory: 2Gi + limits: + cpu: 1 + memory: 4Gi \ No newline at end of file diff --git a/CH07/Listing0720-Generic code to copy a local file to a container.txt b/CH07/Listing0720-Generic code to copy a local file to a container.txt new file mode 100644 index 0000000..e266e08 --- /dev/null +++ b/CH07/Listing0720-Generic code to copy a local file to a container.txt @@ -0,0 +1 @@ +kubectl cp LocalFile TargetPod:TargetFile -c ContainerName \ No newline at end of file diff --git a/CH07/Listing0721-Code to copy a local file to a container.txt b/CH07/Listing0721-Code to copy a local file to a container.txt new file mode 100644 index 0000000..651d94f --- /dev/null +++ b/CH07/Listing0721-Code to copy a local file to a container.txt @@ -0,0 +1 @@ +kubectl cp AdventureWorks2017.bak mssql-deployment-748c745b8d-7pvgn:var/opt/mssql/data/AdventureWorks2017.bak -c mssql \ No newline at end of file diff --git "a/CH08/Listing0801-Create and switch to namespace \342\200\234monitoring\342\200\235.txt" "b/CH08/Listing0801-Create and switch to namespace \342\200\234monitoring\342\200\235.txt" new file mode 100644 index 0000000..4f76385 --- /dev/null +++ "b/CH08/Listing0801-Create and switch to namespace \342\200\234monitoring\342\200\235.txt" @@ -0,0 +1,2 @@ +kubectl create namespace monitoring +kubectl config set-context --current --namespace=monitoring diff --git a/CH08/Listing0802-Set variables and secrets for InfluxDB.txt b/CH08/Listing0802-Set variables and secrets for InfluxDB.txt new file mode 100644 index 0000000..ba53da6 --- /dev/null +++ b/CH08/Listing0802-Set variables and secrets for InfluxDB.txt @@ -0,0 +1,10 @@ +kubectl create secret generic influxdb-creds \ +--from-literal=INFLUXDB_DB=monitoring \ +--from-literal=INFLUXDB_USER=user \ +--from-literal=INFLUXDB_USER_PASSWORD=user\ +--from-literal=INFLUXDB_READ_USER=readonly \ +--from-literal=INFLUXDB_READ_USER_PASSWORD=readonly \ +--from-literal=INFLUXDB_ADMIN_USER=admin \ +--from-literal=INFLUXDB_ADMIN_USER_PASSWORD=admin \ +--from-literal=INFLUXDB_HOST=influxdb \ +--from-literal=INFLUXDB_HTTP_AUTH_ENABLED=false \ No newline at end of file diff --git a/CH08/Listing0803-Set variables and secrets for Grafana.txt b/CH08/Listing0803-Set variables and secrets for Grafana.txt new file mode 100644 index 0000000..48a65f1 --- /dev/null +++ b/CH08/Listing0803-Set variables and secrets for Grafana.txt @@ -0,0 +1,4 @@ +kubectl create secret generic grafana-creds \ +--from-literal=GF_SECURITY_ADMIN_USER=admin \ +--from-literal=GF_SECURITY_ADMIN_PASSWORD=admin123 \ +--from-literal=GF_INSTALL_PLUGINS=grafana-piechart-panel,grafana-clock-panel \ No newline at end of file diff --git a/CH08/Listing0804-influxdb-storage.yaml.txt b/CH08/Listing0804-influxdb-storage.yaml.txt new file mode 100644 index 0000000..e9c551c --- /dev/null +++ b/CH08/Listing0804-influxdb-storage.yaml.txt @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: pv-nfs-influxdb + labels: + disk: influxdb +spec: + capacity: + storage: 5Gi + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + nfs: + server: storage + path: "/srv/exports/volumes/influxdb" +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pvc-nfs-influxdb +spec: + selector: + matchLabels: + disk: influxdb + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi \ No newline at end of file diff --git a/CH08/Listing0805-influxdb-deployment.yaml.txt b/CH08/Listing0805-influxdb-deployment.yaml.txt new file mode 100644 index 0000000..41b38b6 --- /dev/null +++ b/CH08/Listing0805-influxdb-deployment.yaml.txt @@ -0,0 +1,30 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: monitoring + labels: + app: influxdb + name: influxdb +spec: + replicas: 1 + selector: + matchLabels: + app: influxdb + template: + metadata: + labels: + app: influxdb + spec: + containers: + - envFrom: + - secretRef: + name: influxdb-creds + image: docker.io/influxdb:1.8 + name: influxdb + volumeMounts: + - mountPath: /var/lib/influxdb + name: var-lib-influxdb + volumes: + - name: var-lib-influxdb + persistentVolumeClaim: + claimName: pvc-nfs-influxdb \ No newline at end of file diff --git a/CH08/Listing0806-influxdb-service.yaml.txt b/CH08/Listing0806-influxdb-service.yaml.txt new file mode 100644 index 0000000..d99e4d4 --- /dev/null +++ b/CH08/Listing0806-influxdb-service.yaml.txt @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: influxdb + name: influxdb + namespace: monitoring +spec: + ports: + - port: 8086 + protocol: TCP + targetPort: 8086 + nodePort: 30010 + selector: + app: influxdb + type: NodePort \ No newline at end of file diff --git a/CH08/Listing0807-telegraf-configmap.yaml.txt b/CH08/Listing0807-telegraf-configmap.yaml.txt new file mode 100644 index 0000000..670636e --- /dev/null +++ b/CH08/Listing0807-telegraf-configmap.yaml.txt @@ -0,0 +1,39 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: telegraf + namespace: monitoring + labels: + k8s-app: telegraf +data: + telegraf.conf: |+ + [global_tags] + env = "kubeadm" + [agent] + hostname = "$HOSTNAME" + [[outputs.influxdb]] + urls = ["http://$INFLUXDB_HOST:8086/"] # required + database = "$INFLUXDB_DB" # required + timeout = "5s" + username = "$INFLUXDB_USER" + password = "$INFLUXDB_USER_PASSWORD" + [[inputs.cpu]] + percpu = true + totalcpu = true + collect_cpu_time = false + report_active = false + [[inputs.disk]] + ignore_fs = ["tmpfs", "devtmpfs", "devfs"] + [[inputs.diskio]] + [[inputs.kernel]] + [[inputs.mem]] + [[inputs.processes]] + [[inputs.swap]] + [[inputs.system]] + [[inputs.docker]] + endpoint = "unix:///var/run/docker.sock" + [[inputs.sqlserver]] + servers = [ + "Server=control;Port=;User Id=sa;Password=;app name=telegraf;log=1;" + ] + query_version = 2 \ No newline at end of file diff --git a/CH08/Listing0808-telegraf-daemonset.yaml.txt b/CH08/Listing0808-telegraf-daemonset.yaml.txt new file mode 100644 index 0000000..c0f9227 --- /dev/null +++ b/CH08/Listing0808-telegraf-daemonset.yaml.txt @@ -0,0 +1,79 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: telegraf + namespace: monitoring + labels: + k8s-app: telegraf +spec: + selector: + matchLabels: + name: telegraf + template: + metadata: + labels: + name: telegraf + spec: + containers: + - name: telegraf + image: docker.io/telegraf:latest + env: + - name: HOSTNAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: "HOST_PROC" + value: "/rootfs/proc" + - name: "HOST_SYS" + value: "/rootfs/sys" + - name: INFLUXDB_USER + valueFrom: + secretKeyRef: + name: influxdb-creds + key: INFLUXDB_USER + - name: INFLUXDB_USER_PASSWORD + valueFrom: + secretKeyRef: + name: influxdb-creds + key: INFLUXDB_USER_PASSWORD + - name: INFLUXDB_HOST + valueFrom: + secretKeyRef: + name: influxdb-creds + key: INFLUXDB_HOST + - name: INFLUXDB_DB + valueFrom: + secretKeyRef: + name: influxdb-creds + key: INFLUXDB_DB + volumeMounts: + - name: sys + mountPath: /rootfs/sys + readOnly: true + - name: proc + mountPath: /rootfs/proc + readOnly: true + - name: docker-socket + mountPath: /var/run/docker.sock + - name: utmp + mountPath: /var/run/utmp + readOnly: true + - name: config + mountPath: /etc/telegraf + terminationGracePeriodSeconds: 30 + volumes: + - name: sys + hostPath: + path: /sys + - name: docker-socket + hostPath: + path: /var/run/docker.sock + - name: proc + hostPath: + path: /proc + - name: utmp + hostPath: + path: /var/run/utmp + - name: config + configMap: + name: telegraf \ No newline at end of file diff --git a/CH08/Listing0809-grafana-storage.yaml.txt b/CH08/Listing0809-grafana-storage.yaml.txt new file mode 100644 index 0000000..e459dd2 --- /dev/null +++ b/CH08/Listing0809-grafana-storage.yaml.txt @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: pv-nfs-grafana + labels: + disk: grafana +spec: + capacity: + storage: 5Gi + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + nfs: + server: storage + path: "/srv/exports/volumes/grafana" +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pvc-nfs-grafana +spec: + selector: + matchLabels: + disk: grafana + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi \ No newline at end of file diff --git a/CH08/Listing0810-grafana-deployment.yaml.txt b/CH08/Listing0810-grafana-deployment.yaml.txt new file mode 100644 index 0000000..350a1ec --- /dev/null +++ b/CH08/Listing0810-grafana-deployment.yaml.txt @@ -0,0 +1,36 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: monitoring + labels: + app: grafana + name: grafana +spec: + replicas: 1 + selector: + matchLabels: + app: grafana + template: + metadata: + labels: + app: grafana + spec: + containers: + - envFrom: + - secretRef: + name: grafana-creds + image: docker.io/grafana/grafana:7.3.3 + name: grafana + volumeMounts: + - name: data-dir + mountPath: /var/lib/grafana/ + securityContext: + fsGroup: 472 + runAsGroup: 472 + runAsNonRoot: true + runAsUser: 472 + + volumes: + - name: data-dir + persistentVolumeClaim: + claimName: pvc-nfs-grafana \ No newline at end of file diff --git a/CH08/Listing0811-grafana-service.yaml.txt b/CH08/Listing0811-grafana-service.yaml.txt new file mode 100644 index 0000000..d147873 --- /dev/null +++ b/CH08/Listing0811-grafana-service.yaml.txt @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: grafana + name: grafana + namespace: monitoring +spec: + ports: + - port: 443 + name: https + targetPort: 3000 + nodePort: 30080 + selector: + app: grafana + type: NodePort \ No newline at end of file diff --git "a/CH08/Listing0812-Create and switch to namespace \342\200\234logging\342\200\235.txt" "b/CH08/Listing0812-Create and switch to namespace \342\200\234logging\342\200\235.txt" new file mode 100644 index 0000000..4596f05 --- /dev/null +++ "b/CH08/Listing0812-Create and switch to namespace \342\200\234logging\342\200\235.txt" @@ -0,0 +1,2 @@ +kubectl create namespace logging +kubectl config set-context --current --namespace=logging \ No newline at end of file diff --git a/CH08/Listing0813-elasticsearch-service.yaml.txt b/CH08/Listing0813-elasticsearch-service.yaml.txt new file mode 100644 index 0000000..67eecc1 --- /dev/null +++ b/CH08/Listing0813-elasticsearch-service.yaml.txt @@ -0,0 +1,16 @@ +kind: Service +apiVersion: v1 +metadata: + name: elasticsearch + namespace: logging + labels: + app: elasticsearch +spec: + selector: + app: elasticsearch + clusterIP: None + ports: + - port: 9200 + name: rest + - port: 9300 + name: inter-node \ No newline at end of file diff --git a/CH08/Listing0814-Deploy elasticsearch as a StatefulSet (elasticsearch.yaml).txt b/CH08/Listing0814-Deploy elasticsearch as a StatefulSet (elasticsearch.yaml).txt new file mode 100644 index 0000000..d2da537 --- /dev/null +++ b/CH08/Listing0814-Deploy elasticsearch as a StatefulSet (elasticsearch.yaml).txt @@ -0,0 +1,77 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: es-cluster + namespace: logging +spec: + serviceName: elasticsearch + replicas: 3 + selector: + matchLabels: + app: elasticsearch + template: + metadata: + labels: + app: elasticsearch + spec: + containers: + - name: elasticsearch + image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0 + resources: + limits: + cpu: 1000m + requests: + cpu: 100m + ports: + - containerPort: 9200 + name: rest + protocol: TCP + - containerPort: 9300 + name: inter-node + protocol: TCP + volumeMounts: + - name: data + mountPath: /usr/share/elasticsearch/data + env: + - name: cluster.name + value: k8s-logs + - name: node.name + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: discovery.seed_hosts + value: "es-cluster-0.elasticsearch,es-cluster-1.elasticsearch,es-cluster-2.elasticsearch" + - name: cluster.initial_master_nodes + value: "es-cluster-0,es-cluster-1,es-cluster-2" + - name: ES_JAVA_OPTS + value: "-Xms512m -Xmx512m" + initContainers: + - name: fix-permissions + image: busybox + command: ["sh", "-c", "chown -R 1000:1000 /usr/share/elasticsearch/data"] + securityContext: + privileged: true + volumeMounts: + - name: data + mountPath: /usr/share/elasticsearch/data + - name: increase-vm-max-map + image: busybox + command: ["sysctl", "-w", "vm.max_map_count=262144"] + securityContext: + privileged: true + - name: increase-fd-ulimit + image: busybox + command: ["sh", "-c", "ulimit -n 65536"] + securityContext: + privileged: true + volumeClaimTemplates: + - metadata: + name: data + labels: + app: elasticsearch + spec: + accessModes: [ "ReadWriteOnce" ] + storageClassName: nfs-storage + resources: + requests: + storage: 100Gi diff --git a/CH08/Listing0815-kibana.yaml.txt b/CH08/Listing0815-kibana.yaml.txt new file mode 100644 index 0000000..636b019 --- /dev/null +++ b/CH08/Listing0815-kibana.yaml.txt @@ -0,0 +1,47 @@ +apiVersion: v1 +kind: Service +metadata: + name: kibana + namespace: logging + labels: + app: kibana +spec: + ports: + - port: 5601 + targetPort: 5601 + nodePort: 30445 + selector: + app: kibana + type: NodePort +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: kibana + namespace: logging + labels: + app: kibana +spec: + replicas: 1 + selector: + matchLabels: + app: kibana + template: + metadata: + labels: + app: kibana + spec: + containers: + - name: kibana + image: docker.elastic.co/kibana/kibana:7.2.0 + resources: + limits: + cpu: 1000m + requests: + cpu: 100m + env: + - name: ELASTICSEARCH_URL + value: http://elasticsearch:9200 + ports: + - containerPort: 5601 + diff --git a/CH08/Listing0816-Install fluent-bit.txt b/CH08/Listing0816-Install fluent-bit.txt new file mode 100644 index 0000000..a027e51 --- /dev/null +++ b/CH08/Listing0816-Install fluent-bit.txt @@ -0,0 +1,5 @@ +kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-service-account.yaml +kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-role.yaml +kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-role-binding.yaml +kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/output/elasticsearch/fluent-bit-configmap.yaml +kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/output/elasticsearch/fluent-bit-ds.yaml diff --git a/CH08/Listing0817-Reset kubectl context.txt b/CH08/Listing0817-Reset kubectl context.txt new file mode 100644 index 0000000..369c896 --- /dev/null +++ b/CH08/Listing0817-Reset kubectl context.txt @@ -0,0 +1 @@ +kubectl config set-context --current --namespace=default \ No newline at end of file diff --git a/CH09/Listing0901-Switch kubectl context to AKSCluster.txt b/CH09/Listing0901-Switch kubectl context to AKSCluster.txt new file mode 100644 index 0000000..30b5e5b --- /dev/null +++ b/CH09/Listing0901-Switch kubectl context to AKSCluster.txt @@ -0,0 +1 @@ +kubectl config use-context AKSCluster \ No newline at end of file diff --git a/CH09/Listing0902- List storage classes in AKSCluster.txt b/CH09/Listing0902- List storage classes in AKSCluster.txt new file mode 100644 index 0000000..9a37ec5 --- /dev/null +++ b/CH09/Listing0902- List storage classes in AKSCluster.txt @@ -0,0 +1 @@ +kubectl get storageclass \ No newline at end of file diff --git a/CH09/Listing0903-azdata command to create a Data Controller.txt b/CH09/Listing0903-azdata command to create a Data Controller.txt new file mode 100644 index 0000000..9475d6d --- /dev/null +++ b/CH09/Listing0903-azdata command to create a Data Controller.txt @@ -0,0 +1,9 @@ +azdata arc dc create \ +--connectivity-mode Indirect \ +--name arc-dc-aks \ +--namespace arc \ +--subscription \ +--resource-group "Kubernetes-Cloud" \ +--location eastus \ +--storage-class managed-premium \ +--profile-name azure-arc-aks-premium-storage diff --git a/CH09/Listing0904-azdata command to list profile names for Data Controller.txt b/CH09/Listing0904-azdata command to list profile names for Data Controller.txt new file mode 100644 index 0000000..3327a55 --- /dev/null +++ b/CH09/Listing0904-azdata command to list profile names for Data Controller.txt @@ -0,0 +1 @@ +azdata arc dc config list \ No newline at end of file diff --git a/CH09/Listing0905-Monitor deployment status using kubectl.txt b/CH09/Listing0905-Monitor deployment status using kubectl.txt new file mode 100644 index 0000000..5923e90 --- /dev/null +++ b/CH09/Listing0905-Monitor deployment status using kubectl.txt @@ -0,0 +1 @@ +kubectl get pods -n arc –watch \ No newline at end of file diff --git a/CH09/Listing0906-azdata command to log in to your Data Controller.txt b/CH09/Listing0906-azdata command to log in to your Data Controller.txt new file mode 100644 index 0000000..17db1fa --- /dev/null +++ b/CH09/Listing0906-azdata command to log in to your Data Controller.txt @@ -0,0 +1 @@ +azdata login -ns arc \ No newline at end of file diff --git a/CH09/Listing0907-azdata command to create a new SQL Managed Instance with parameters.txt b/CH09/Listing0907-azdata command to create a new SQL Managed Instance with parameters.txt new file mode 100644 index 0000000..f7f5132 --- /dev/null +++ b/CH09/Listing0907-azdata command to create a new SQL Managed Instance with parameters.txt @@ -0,0 +1,6 @@ +azdata arc sql mi create \ +--name arc-mi-01 \ +--storage-class-data managed-premium \ +--storage-class-logs managed-premium \ +--storage-class-data-logs managed-premium \ +--storage-class-backups managed-premium diff --git a/CH09/Listing0908-kubectl get pods.txt b/CH09/Listing0908-kubectl get pods.txt new file mode 100644 index 0000000..2154fb5 --- /dev/null +++ b/CH09/Listing0908-kubectl get pods.txt @@ -0,0 +1 @@ +kubectl get pods arc-mi-01-0 -n arc \ No newline at end of file diff --git a/CH09/Listing0909-azdata command to list all SQL MIs in the current controller.txt b/CH09/Listing0909-azdata command to list all SQL MIs in the current controller.txt new file mode 100644 index 0000000..2f693c4 --- /dev/null +++ b/CH09/Listing0909-azdata command to list all SQL MIs in the current controller.txt @@ -0,0 +1 @@ +azdata arc sql mi list \ No newline at end of file diff --git a/CH09/Listing0910-azdata command to create a new SQL Managed Instance with parameters.txt b/CH09/Listing0910-azdata command to create a new SQL Managed Instance with parameters.txt new file mode 100644 index 0000000..2b1b7ef --- /dev/null +++ b/CH09/Listing0910-azdata command to create a new SQL Managed Instance with parameters.txt @@ -0,0 +1,3 @@ +azdata arc sql mi create \ +--name arc-mi-ha \ +--replicas 3 diff --git a/CH09/Listing0911-Get AG Health through T-SQL.txt b/CH09/Listing0911-Get AG Health through T-SQL.txt new file mode 100644 index 0000000..75fbbb2 --- /dev/null +++ b/CH09/Listing0911-Get AG Health through T-SQL.txt @@ -0,0 +1 @@ +SELECT ag.name agname, ags.* FROM sys.dm_hadr_availability_group_states ags INNER JOIN sys.availability_groups ag ON ag.group_id = ags.group_id \ No newline at end of file diff --git a/CH10/Listing 10-1. Create a BDC configuration.txt b/CH10/Listing 10-1. Create a BDC configuration.txt new file mode 100644 index 0000000..064955a --- /dev/null +++ b/CH10/Listing 10-1. Create a BDC configuration.txt @@ -0,0 +1 @@ +azdata bdc config init [--path] [--source -s] \ No newline at end of file diff --git a/CH10/Listing 10-2. Create a BDC configuration.txt b/CH10/Listing 10-2. Create a BDC configuration.txt new file mode 100644 index 0000000..7a435f6 --- /dev/null +++ b/CH10/Listing 10-2. Create a BDC configuration.txt @@ -0,0 +1 @@ +azdata bdc config init --path myBDC –-source aks-dev-test \ No newline at end of file diff --git a/CH10/Listing 10-3. Sample bdc.json.txt b/CH10/Listing 10-3. Sample bdc.json.txt new file mode 100644 index 0000000..cb37571 --- /dev/null +++ b/CH10/Listing 10-3. Sample bdc.json.txt @@ -0,0 +1,155 @@ +{ + "apiVersion": "v1", + "metadata": { + "kind": "BigDataCluster", + "name": "mssql-cluster" + }, + "spec": { + "resources": { + "nmnode-0": { + "spec": { + "replicas": 2 + } + }, + "sparkhead": { + "spec": { + "replicas": 2 + } + }, + "zookeeper": { + "spec": { + "replicas": 3 + } + }, + "gateway": { + "spec": { + "replicas": 1, + "endpoints": [ + { + "name": "Knox", + "dnsName": "", + "serviceType": "NodePort", + "port": 30443 + } + ] + } + }, + "appproxy": { + "spec": { + "replicas": 1, + "endpoints": [ + { + "name": "AppServiceProxy", + "dnsName": "", + "serviceType": "NodePort", + "port": 30778 + } + ] + } + }, + "master": { + "metadata": { + "kind": "Pool", + "name": "default" + }, + "spec": { + "type": "Master", + "replicas": 3, + "endpoints": [ + { + "name": "Master", + "dnsName": "", + "serviceType": "NodePort", + "port": 31433 + }, + { + "name": "MasterSecondary", + "dnsName": "", + "serviceType": "NodePort", + "port": 31436 + } + ], + "settings": { + "sql": { + "hadr.enabled": "true" + } + } + } + }, + "compute-0": { + "metadata": { + "kind": "Pool", + "name": "default" + }, + "spec": { + "type": "Compute", + "replicas": 1 + } + }, + "data-0": { + "metadata": { + "kind": "Pool", + "name": "default" + }, + "spec": { + "type": "Data", + "replicas": 2 + } + }, + "storage-0": { + "metadata": { + "kind": "Pool", + "name": "default" + }, + "spec": { + "type": "Storage", + "replicas": 3, + "settings": { + "spark": { + "includeSpark": "true" + } + } + } + } + }, + "services": { + "sql": { + "resources": [ + "master", + "compute-0", + "data-0", + "storage-0" + ] + }, + "hdfs": { + "resources": [ + "nmnode-0", + "zookeeper", + "storage-0", + "sparkhead" + ], + "settings": { + "hdfs-site.dfs.replication": "3" + } + }, + "spark": { + "resources": [ + "sparkhead", + "storage-0" + ], + "settings": { + "spark-defaults-conf.spark.driver.memory": "2g", + "spark-defaults-conf.spark.driver.cores": "1", + "spark-defaults-conf.spark.executor.instances": "3", + "spark-defaults-conf.spark.executor.memory": "1536m", + "spark-defaults-conf.spark.executor.cores": "1", + "yarn-site.yarn.nodemanager.resource.memory-mb": "18432", + "yarn-site.yarn.nodemanager.resource.cpu-vcores": "6", + "yarn-site.yarn.scheduler.maximum-allocation-mb": "18432", + "yarn-site.yarn.scheduler.maximum-allocation-vcores": "6", + "yarn-site.yarn.scheduler.capacity.maximum-am-resource-percent": "0.3" + } + } + } + } +} diff --git a/CH10/Listing 10-4. Create cluster using azdata.txt b/CH10/Listing 10-4. Create cluster using azdata.txt new file mode 100644 index 0000000..8c24d85 --- /dev/null +++ b/CH10/Listing 10-4. Create cluster using azdata.txt @@ -0,0 +1 @@ +azdata bdc create -c < yourPath> --accept-eula yes \ No newline at end of file diff --git a/CH10/Listing 10-5. Update azdata to the latest version.txt b/CH10/Listing 10-5. Update azdata to the latest version.txt new file mode 100644 index 0000000..4f5b327 --- /dev/null +++ b/CH10/Listing 10-5. Update azdata to the latest version.txt @@ -0,0 +1,2 @@ +curl -o azdata.msi https://aka.ms/azdata-msi +msiexec azdata.msi diff --git a/CH10/Listing 10-6. Upgrade your BDC to CU9 using azdata.txt b/CH10/Listing 10-6. Upgrade your BDC to CU9 using azdata.txt new file mode 100644 index 0000000..131f780 --- /dev/null +++ b/CH10/Listing 10-6. Upgrade your BDC to CU9 using azdata.txt @@ -0,0 +1 @@ +azdata bdc upgrade --name mybdc --tag 2019-CU9-ubuntu-16.04 \ No newline at end of file