diff --git a/App/v1/Dockerfile b/App/v1/Dockerfile index 6b23026..5849cb7 100644 --- a/App/v1/Dockerfile +++ b/App/v1/Dockerfile @@ -1,6 +1,6 @@ FROM node:current-slim -LABEL MAINTAINER=nigelpoulton@hotmail.com +LABEL MAINTAINER=hnguyenva60@@gmail.com # Copy source code to /src in container COPY . /src diff --git a/Deployments/AzureDisk.yaml b/Deployments/AzureDisk.yaml new file mode 100644 index 0000000..9ecf79f --- /dev/null +++ b/Deployments/AzureDisk.yaml @@ -0,0 +1,43 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pvc-azure-managed +spec: + accessModes: + - ReadWriteOnce + storageClassName: managed-premium + resources: + requests: + storage: 10Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-azdisk-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + volumes: + - name: webcontent + persistentVolumeClaim: + claimName: pvc-azure-managed + containers: + - name: nginx + image: nginx + ports: + - containerPort: 80 + volumeMounts: + - name: webcontent + mountPath: "/usr/share/nginx/html/web-app" + + + + + diff --git a/Deployments/AzureDiskCustomStorageClass.yaml b/Deployments/AzureDiskCustomStorageClass.yaml new file mode 100644 index 0000000..f8612ca --- /dev/null +++ b/Deployments/AzureDiskCustomStorageClass.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pvc-azure-standard-ssd + spec: + accessModes: + - ReadWriteOnce + storageClassName: managed-standard-ssd + resources: + requests: + storage: 10Gi +--- + + + + diff --git a/Deployments/CoreDNSConfigCustom.yaml b/Deployments/CoreDNSConfigCustom.yaml new file mode 100644 index 0000000..ab0cc1b --- /dev/null +++ b/Deployments/CoreDNSConfigCustom.yaml @@ -0,0 +1,26 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: coredns + namespace: kube-system +data: + Corefile: | + .:53 { + errors + health + ready + kubernetes cluster.local in-addr.arpa ip6.arpa { + pod insecure + fallthrough in-addr.arpa ip6.arpa + ttl 30 + } + prometheus :9153 + forward . 1.1.1.1 + cache 30 + loop + reload + loadbalance + } + centinosystems.com { + forward . 9.9.9.9 + } \ No newline at end of file diff --git a/Deployments/CreateUserCertificate.sh b/Deployments/CreateUserCertificate.sh new file mode 100644 index 0000000..d17d829 --- /dev/null +++ b/Deployments/CreateUserCertificate.sh @@ -0,0 +1,13 @@ +cat <Welcome \ No newline at end of file diff --git a/Deployments/create_CSR1.yaml b/Deployments/create_CSR1.yaml new file mode 100644 index 0000000..a8d3355 --- /dev/null +++ b/Deployments/create_CSR1.yaml @@ -0,0 +1,10 @@ +# Create a private key +openssl genrsa -out demouser.key 2048 + +# Generate a CSR +# CN (Common Name) is your username, O (Oraganization) is the Group +openssl req -new -key demouser.key -out demouser.csr -subj "CN=demounser" + +# The CertificateSigningRequest needs to be base64 encoded +# And also have the header and trailer pulled out. +cat demouser.csr | base64 | tr -d "\n" > demouser.base64.csr diff --git a/Deployments/create_roleBinding.yaml b/Deployments/create_roleBinding.yaml new file mode 100644 index 0000000..e69de29 diff --git a/Deployments/demouser.csr b/Deployments/demouser.csr new file mode 100644 index 0000000..0ae3461 --- /dev/null +++ b/Deployments/demouser.csr @@ -0,0 +1,15 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIICWDCCAUACAQAwEzERMA8GA1UEAwwIZGVtb3VzZXIwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQCdpLkIHcUvYI+j44RcuKz6SGmLzIJSrh7/vKX6Lf+W +g/vA97wLo+M7QE1zfgQ+MDt3hExuZdHODKZpXpJ8x2u5qPlR5zMiNz7m85y1sS/n +et2FsTsdoNRV9T3/bZOvCq4vGPOAg4bP4PoeN0fcUjUnOEAbRG0n2ySfZCoerAJh +HCTidsAEvobVErwMDyzvJg9ssEQKiRbPGvEysf4/wnD26WiE8XjdM2JhzU9GpaJf +DUi/l1fVLyLg5cGjyPYee4PGIkhvTvmTCuO1+hJfuWlnl/Od/6tMEWWaCXONX7pW +WJzctK2QQkBlfJSMbXmcLefypDR1YB/mw0J5VYsxUTvdAgMBAAGgADANBgkqhkiG +9w0BAQsFAAOCAQEAfMsjvPvPQBoI70JZtFSbN6t4Mn1e++aWb0pEdNp11lnOrobr +gznLLX48LRGL3iCDAfyiAFdKbspWzYt2eH2Z0/iv7mc6Hx/0JT3AcXkn2qU9NNgv +PiCZ5Dg33iWDZoVcGcwOnqn7Gj16xm52yovWWcDJ4Q9iOtv0RmopWWfvLyewwveE +Iq8YGaiFueT9POl9JFvXoLP3dZK5YrcTXDFw7QvIGWkxWpVBQtEFA3DKIFvUzq/S +OWyWLWqqV9OFEZlYS8zsUhgEkKS9nUTLDdfk8G6LrSaps2dzetWpQyNVYMtivDEG +1bpX53G5VpFuC3TiJQHmlYbyOFyrsoJpFK/QuA== +-----END CERTIFICATE REQUEST----- diff --git a/Deployments/demouser.key b/Deployments/demouser.key new file mode 100644 index 0000000..4b67ea0 --- /dev/null +++ b/Deployments/demouser.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAnaS5CB3FL2CPo+OEXLis+khpi8yCUq4e/7yl+i3/loP7wPe8 +C6PjO0BNc34EPjA7d4RMbmXRzgymaV6SfMdruaj5UeczIjc+5vOctbEv53rdhbE7 +HaDUVfU9/22TrwquLxjzgIOGz+D6HjdH3FI1JzhAG0RtJ9skn2QqHqwCYRwk4nbA +BL6G1RK8DA8s7yYPbLBECokWzxrxMrH+P8Jw9ulohPF43TNiYc1PRqWiXw1Iv5dX +1S8i4OXBo8j2HnuDxiJIb075kwrjtfoSX7lpZ5fznf+rTBFlmglzjV+6Vlic3LSt +kEJAZXyUjG15nC3n8qQ0dWAf5sNCeVWLMVE73QIDAQABAoIBAQCS4RVdUI+Wsvti +keuTkKXqlGlyzdtnOcC8OoLS9OS80sBQbQISPmLLpAAF6ZX+c2YU13l3KvsuZm7u +oiUOiaf/VkbmXuovqRW8jaKnTy35GWso05bm5iCw7k0Tnn8JioP8cdz/Eo0bRt0E +JjGYQCgyIKDqRvkFN5OJxwPPjCizXNVIzIrMCv0YyWoInn4QU0if03KfJG15XKyC +yGObv4jGbOUMnlr10sAvMoX18uHPuiRE5i2J7rl9xmHs3MyoqQvNJfvyrrPY8DTT +UfujdQosiZqsU05bXLVh9UZnlDqK7MPtynG0hgCzXA/oup6OF38JlscV9EsNkVgs +HKS00CupAoGBAMs3R6IVdBenTmBzcnZLsl31il7TCWWE/ZzYHo0I3hmT3Bg4hpJw +kYB0/Ne5TVlhK7/6oZHJeGKW/D0YgozpWgUkZV56a0ie9QhnD0o30RpOdLXJUDFM +DxraG6e0CdP0p1B8RHea55zun7abN58uce5mAR1EUBIDkmWAAR/HqyQXAoGBAMaX +IMfJHXg11MfJYGxJNTAj4IiPmmeAysFeUfrClHbjpP/DbWAbBexH2LAQg9iFsRYR +U/nyrOa5HQ+lB82CnfvPN/mKl0+ORF5qt9bmH/pezxO2sVOnKo/HrH41m+Nqud05 +UA6FI9ATI0DHxRZi4Can2vTcWBW6WsnzajvUnrQrAoGAMOoyfOpLEnJ8JC1FzQG1 +gnZbAy4rIducLEe9Otd6lo+Ht/DLO66K52/BeK+q1avVGxXaFDx5lMmhF5exvPdi +asBzAgXXkxhoBMjB3myHEZz27NbzTZpwPFdptrlYcEOAjpgK5vtLavPpT8wW3GMS +m37EH+ZUm7FuaK4iFyM5p6sCgYEAmZX1/y02Qmr3hg/jJ7wyi2mj1FmjY5sCtCv7 +IQFtiskiKb/9jg84NHWYSwpqvYEf5N4/4RXizImrxRawAyuafU3Uj4S04w03KQJF +7ciKQLskUa3AVN77FrmpWO6jAm3fEw2pMaGcgebbI9WcQmTz0FGPEEJ9SUiXwIol +xeH5X4MCgYAo5br/v7YasCZq48Mkn6eIUBEJ0j7ezLdT74hKmf70Jp21weApNbj2 +TNtC3XxnXCEH5CPx/TE+IWZlPOvOg8WK/8agSqbQuL4JB3D2JfgsSlNXxHvLlBv4 +0ixNGmmJnUpb7jqkRh3ZURNSIuhaQ/LDo66snEJvhdNk5ogiUVuB/w== +-----END RSA PRIVATE KEY----- diff --git a/Deployments/deploy-complete.yml b/Deployments/deploy-complete.yaml similarity index 97% rename from Deployments/deploy-complete.yml rename to Deployments/deploy-complete.yaml index ac3ba08..6d39160 100644 --- a/Deployments/deploy-complete.yml +++ b/Deployments/deploy-complete.yaml @@ -9,7 +9,7 @@ spec: selector: matchLabels: app: web - replicas: 5 + replicas: 3 minReadySeconds: 5 strategy: type: RollingUpdate diff --git a/Deployments/deploy.yml b/Deployments/deploy.yaml similarity index 97% rename from Deployments/deploy.yml rename to Deployments/deploy.yaml index af2b037..f515dcc 100644 --- a/Deployments/deploy.yml +++ b/Deployments/deploy.yaml @@ -6,7 +6,7 @@ metadata: labels: app: web spec: - replicas: 5 + replicas: 3 selector: matchLabels: app: web diff --git a/Deployments/deployNginx.yaml b/Deployments/deployNginx.yaml new file mode 100644 index 0000000..d2bc980 --- /dev/null +++ b/Deployments/deployNginx.yaml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment + labels: + app: nginx +spec: + replicas: 3 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 8080 \ No newline at end of file diff --git a/Deployments/deployment-Ubuntu.yaml b/Deployments/deployment-Ubuntu.yaml new file mode 100644 index 0000000..ced8dd7 --- /dev/null +++ b/Deployments/deployment-Ubuntu.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: ubuntu + labels: + app: ubuntu +spec: + containers: + - image: ubuntu + command: + - "sleep" + - "604800" + imagePullPolicy: IfNotPresent + name: ubuntu + restartPolicy: Always \ No newline at end of file diff --git a/Deployments/deployment-Ubuntu3.yaml b/Deployments/deployment-Ubuntu3.yaml new file mode 100644 index 0000000..23fa116 --- /dev/null +++ b/Deployments/deployment-Ubuntu3.yaml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ubuntu-deployment + labels: + app: ubuntu +spec: + replicas: 3 + selector: + matchLabels: + app: ubuntu + template: + metadata: + labels: + app: ubuntu + spec: + containers: + - name: ubuntu + image: ubuntu + command: ["sleep", "123456"] + nodeSelector: + kubernetes.io/os: linux \ No newline at end of file diff --git a/Deployments/deployment-alpha.yaml b/Deployments/deployment-alpha.yaml new file mode 100644 index 0000000..d29f28b --- /dev/null +++ b/Deployments/deployment-alpha.yaml @@ -0,0 +1,37 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-world-alpha +spec: + replicas: 1 + selector: + matchLabels: + app: hello-world-alpha + template: + metadata: + labels: + app: hello-world-alpha + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:1.0 + env: + - name: DATABASE_SERVERNAME + value: "sql.example.local" + - name: BACKEND_SERVERNAME + value: "be.example.local" + ports: + - containerPort: 8080 +--- +apiVersion: v1 +kind: Service +metadata: + name: hello-world-alpha +spec: + selector: + app: hello-world-alpha + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + diff --git a/Deployments/deployment-beta.yaml b/Deployments/deployment-beta.yaml new file mode 100644 index 0000000..7446b70 --- /dev/null +++ b/Deployments/deployment-beta.yaml @@ -0,0 +1,39 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-world-beta +spec: + replicas: 1 + selector: + matchLabels: + app: hello-world-beta + template: + metadata: + labels: + app: hello-world-beta + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:1.0 + env: + - name: DATABASE_SERVERNAME + value: "sql.example.local" + - name: BACKEND_SERVERNAME + value: "be.example.local" + ports: + - containerPort: 8080 +--- +apiVersion: v1 +kind: Service +metadata: + name: hello-world-beta +spec: + selector: + app: hello-world-beta + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + type: ClusterIP + + diff --git a/Deployments/deployment-label.yaml b/Deployments/deployment-label.yaml new file mode 100644 index 0000000..453ad47 --- /dev/null +++ b/Deployments/deployment-label.yaml @@ -0,0 +1,22 @@ +# Simple deployment used to deploy and manage the app in nigelpoulton/getting-started-k8s:1.0 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-world + labels: + app: hello-world +spec: + replicas: 5 + selector: + matchLabels: + app: hello-world + template: + metadata: + labels: + app: hello-world + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:1.0 + ports: + - containerPort: 8080 \ No newline at end of file diff --git a/Deployments/deployment-old.yaml b/Deployments/deployment-old.yaml new file mode 100644 index 0000000..5eacfb2 --- /dev/null +++ b/Deployments/deployment-old.yaml @@ -0,0 +1,24 @@ +# Simple deployment used to deploy and manage the app in nigelpoulton/getting-started-k8s:1.0 +apiVersion: apps/v1 +kind: Pod +metadata: + name: web-deploy + labels: + app: web +spec: + replicas: 3 + selector: + matchLabels: + app: web + template: + metadata: + labels: + app: web + spec: + terminationGracePeriodSeconds: 1 + containers: + - name: hello-pod + image: nigelpoulton/getting-started-k8s:1.0 + imagePullPolicy: Always + ports: + - containerPort: 8080 \ No newline at end of file diff --git a/Deployments/deployment-rolling.yaml b/Deployments/deployment-rolling.yaml new file mode 100644 index 0000000..7579095 --- /dev/null +++ b/Deployments/deployment-rolling.yaml @@ -0,0 +1,20 @@ +# Hoang deployment rolling version 2 on 12/07/2023 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-world +spec: + replicas: 20 + selector: + matchLabels: + app: hello-world + template: + metadata: + labels: + app: hello-world + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:1.0 + ports: + - containerPort: 8080 diff --git a/Deployments/deployment.20replicas.yaml b/Deployments/deployment.20replicas.yaml new file mode 100644 index 0000000..f34a3ee --- /dev/null +++ b/Deployments/deployment.20replicas.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-world +spec: + replicas: 20 + selector: + matchLabels: + app: hello-world + template: + metadata: + labels: + app: hello-world + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:1.0 + ports: + - containerPort: 8080 diff --git a/Deployments/deployment.probes-1.yaml b/Deployments/deployment.probes-1.yaml new file mode 100644 index 0000000..36bb8e4 --- /dev/null +++ b/Deployments/deployment.probes-1.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-world +spec: + replicas: 20 + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 10% + maxSurge: 2 + revisionHistoryLimit: 20 + selector: + matchLabels: + app: hello-world + template: + metadata: + labels: + app: hello-world + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:1.0 + ports: + - containerPort: 8080 + readinessProbe: + httpGet: + path: /index.html + port: 8080 + initialDelaySeconds: 10 + periodSeconds: 10 diff --git a/Deployments/deployment.probes-2.yaml b/Deployments/deployment.probes-2.yaml new file mode 100644 index 0000000..c01516d --- /dev/null +++ b/Deployments/deployment.probes-2.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-world +spec: + replicas: 20 + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 10% + maxSurge: 2 + revisionHistoryLimit: 20 + selector: + matchLabels: + app: hello-world + template: + metadata: + labels: + app: hello-world + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:2.0 + ports: + - containerPort: 8080 + readinessProbe: + httpGet: + path: /index.html + port: 8080 + initialDelaySeconds: 10 + periodSeconds: 10 diff --git a/Deployments/deployment.probes-3.yaml b/Deployments/deployment.probes-3.yaml new file mode 100644 index 0000000..d4c04b0 --- /dev/null +++ b/Deployments/deployment.probes-3.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-world +spec: + replicas: 20 + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 10% + maxSurge: 2 + revisionHistoryLimit: 20 + selector: + matchLabels: + app: hello-world + template: + metadata: + labels: + app: hello-world + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:2.0 + ports: + - containerPort: 8080 + readinessProbe: + httpGet: + path: /index.html + port: 8081 + initialDelaySeconds: 10 + periodSeconds: 10 diff --git a/Deployments/deployment.yaml b/Deployments/deployment.yaml new file mode 100644 index 0000000..92c7ebe --- /dev/null +++ b/Deployments/deployment.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-world +spec: + replicas: 3 + selector: + matchLabels: + app: hello-world + template: + metadata: + labels: + app: hello-world + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:1.0 + ports: + - containerPort: 8080 \ No newline at end of file diff --git a/Deployments/deployment2.yaml b/Deployments/deployment2.yaml new file mode 100644 index 0000000..17cd5be --- /dev/null +++ b/Deployments/deployment2.yaml @@ -0,0 +1,20 @@ +# Hoang deployment version 2 on 12/06/2023 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-world +spec: + replicas: 10 + selector: + matchLabels: + app: hello-world + template: + metadata: + labels: + app: hello-world + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:2.0 + ports: + - containerPort: 8080 diff --git a/Deployments/deployment3.broken.yaml b/Deployments/deployment3.broken.yaml new file mode 100644 index 0000000..9b9d808 --- /dev/null +++ b/Deployments/deployment3.broken.yaml @@ -0,0 +1,20 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-world +spec: + progressDeadlineSeconds: 10 + replicas: 10 + selector: + matchLabels: + app: hello-world + template: + metadata: + labels: + app: hello-world + spec: + containers: + - name: hello-pod + image: gcr.io/google-samples/hello-ap:2.0 + ports: + - containerPort: 8080 \ No newline at end of file diff --git a/Deployments/firewalld_enable.yaml b/Deployments/firewalld_enable.yaml new file mode 100644 index 0000000..aaf6b3b --- /dev/null +++ b/Deployments/firewalld_enable.yaml @@ -0,0 +1,8 @@ +- name: Start and enable http in firewall rules + ansible.builtin.systemd: + hosts: redhat + name: firewalld + state: started + enabled: yes + service: http + permanent: yes \ No newline at end of file diff --git a/Deployments/job-failure-OnFailure.yaml b/Deployments/job-failure-OnFailure.yaml new file mode 100644 index 0000000..1b25688 --- /dev/null +++ b/Deployments/job-failure-OnFailure.yaml @@ -0,0 +1,16 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: hello-world-job-fail +spec: + backoffLimit: 2 + template: + spec: + containers: + - name: ubuntu + image: ubuntu + command: + - "/bin/bash" + - "-c" + - "/bin/ech Hello from Pod %(hostname) at $(date)" + restartPolicy: Never \ No newline at end of file diff --git a/Deployments/kind-3workers.yaml b/Deployments/kind-3workers.yaml new file mode 100644 index 0000000..d53e3c1 --- /dev/null +++ b/Deployments/kind-3workers.yaml @@ -0,0 +1,9 @@ +# three node (two workers) cluster config +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + - role: control-plane + - role: worker + - role: worker + - role: worker diff --git a/Deployments/nfs.nginx.yaml b/Deployments/nfs.nginx.yaml new file mode 100644 index 0000000..060c1e1 --- /dev/null +++ b/Deployments/nfs.nginx.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-nfs-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + lables: + app: nginx + spec: + volumes: + - name: webcontent + persistentVolumeClain: + claimName: pvc-nfs-data + containers: + - name: nginx + image: nginx:1.14.2 + 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 diff --git a/Pods/PodsToNodes.yaml b/Pods/PodsToNodes.yaml new file mode 100644 index 0000000..cc87fb9 --- /dev/null +++ b/Pods/PodsToNodes.yaml @@ -0,0 +1,13 @@ +# Simple Kubernetes to deploy Pod +apiVersion: v1 +kind: Pod +metadata: + name: nginx-pod-ssd +spec: + containers: + - name: nginx + image: nginx + ports: + - containerPort: 80 + nodeSelector: + disk: local_ssd diff --git a/Pods/container-probes-startup.yaml b/Pods/container-probes-startup.yaml new file mode 100644 index 0000000..8daefcc --- /dev/null +++ b/Pods/container-probes-startup.yaml @@ -0,0 +1,37 @@ +apiVersion: v1 +kind: Deployment +metadata: + name: hello-world +spec: + replicas: 1 + selector: + matchLabels: + app: hello-world + template: + metadata: + labels: + app: hello-world + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:1.0 + ports: + - containerPort: 8080 + startupProbe: + tcpSocket: + port: 8081 + initialDeplaySeconds: 10 + periodSeconds: 5 + failureThreshold: 1 + livenessProbe: + tcpSocket: + port: 8080 + initialDelaySeconds: 10 + periodSeconds: 5 + readinessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 10 + periodSeconds: 5 + diff --git a/Pods/init-containers.yaml b/Pods/init-containers.yaml new file mode 100644 index 0000000..47e99be --- /dev/null +++ b/Pods/init-containers.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: init-containers +spec: + initContainers: + - name: init-service + image: ubuntu + command: ['sh', '-c', "echo waiting for service; sleep 2"] + - name: init-database + image: ubuntu + command: ['sh', '-c', "echo waiting for database; sleep 2"] + containers: + - name: app-container + image: nginx \ No newline at end of file diff --git a/Pods/multi-pod.yml b/Pods/multi-pod.yaml similarity index 100% rename from Pods/multi-pod.yml rename to Pods/multi-pod.yaml diff --git a/Pods/mypod.yaml b/Pods/mypod.yaml new file mode 100644 index 0000000..54aad27 --- /dev/null +++ b/Pods/mypod.yaml @@ -0,0 +1,15 @@ +# Simple Kubernetes Pod to deploy the app contained in nigelpoulton/getting-started-k8s:1.0 +apiVersion: v1 +kind: Pod +metadata: + creationTimestamp: null + labels: + run: hello-world + name: hello-world +spec: + containers: + - image: nigelpoulton/getting-started-k8s:1.0 + name: hello-world + ports: + - containerPort: 8080 + resources: {} diff --git a/Pods/newPod.yaml b/Pods/newPod.yaml new file mode 100644 index 0000000..cc9ec48 --- /dev/null +++ b/Pods/newPod.yaml @@ -0,0 +1,21 @@ +# new created by Hoang 12/01/2023 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-world +spec: + replicas: 5 + selector: + matchLabels: + app: hello-world + template: + metadata: + labels: + app: hello-world + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:1.0 + ports: + - containerPort: 8080 + diff --git a/Pods/newPod2.yaml b/Pods/newPod2.yaml new file mode 100644 index 0000000..5e4f9ed --- /dev/null +++ b/Pods/newPod2.yaml @@ -0,0 +1,23 @@ +# new created by Hoang 12/01/2023 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-world +spec: + replicas: 5 + selector: + matchExpressions: + - key: app + operator: In + values: + - hello-world-pod-me + template: + metadata: + labels: + app: hello-world-pod-me + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:1.0 + ports: + - containerPort: 8080 \ No newline at end of file diff --git a/Pods/pod-restart-policy.yaml b/Pods/pod-restart-policy.yaml new file mode 100644 index 0000000..8b507e8 --- /dev/null +++ b/Pods/pod-restart-policy.yaml @@ -0,0 +1,20 @@ +# Testing Pod life cycle 2 +apiVersion: v1 +kind: Pod +metadata: + name: hello-world-onfailure-pod +spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:1.0 + restartPolicy: OnFailure +apiVersion: v1 +kind: Pod +metadata: + name: hello-world-never-pod +spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:1.0 + restartPolicy: Never + diff --git a/Pods/pod.yml b/Pods/pod.yaml similarity index 63% rename from Pods/pod.yml rename to Pods/pod.yaml index b1f4e31..d4cda69 100644 --- a/Pods/pod.yml +++ b/Pods/pod.yaml @@ -1,8 +1,8 @@ -# Simple Kubernetes Pod to deploy the app contained in nigelpoulton/getting-started-k8s:1.0 +# testing Pod life cycle apiVersion: v1 kind: Pod metadata: - name: hello-pod + name: hello-world labels: app: web spec: diff --git a/Pods/pod2.yaml b/Pods/pod2.yaml new file mode 100644 index 0000000..54bf57b --- /dev/null +++ b/Pods/pod2.yaml @@ -0,0 +1,13 @@ +# Testing Pod life cycle +apiVersion: v1 +kind: Pod +metadata: + name: hello-world + labels: + app: hello-world +spec: + containers: + - name: hello-world + image: gcr.io/google-samples/hello-app:1.0 + ports: + - containerPort: 8080 \ No newline at end of file diff --git a/Services/service.yaml b/Services/service.yaml new file mode 100644 index 0000000..471b5db --- /dev/null +++ b/Services/service.yaml @@ -0,0 +1,13 @@ +# LoadBalancer Service. Will only work on supported cloud platforms (AKS, EKS, GKE, DOK, IBM, LKE etc...) +# Listens externally on 80 and forwards to Pod/container on 8080 +apiVersion: v1 +kind: Service +metadata: + name: hello-world +spec: + ports: + - port: 80 + protocol: TCP + targetPort: 8080 + selector: + app: hello-world diff --git a/Services/service2.yaml b/Services/service2.yaml new file mode 100644 index 0000000..202e012 --- /dev/null +++ b/Services/service2.yaml @@ -0,0 +1,14 @@ +# +# Listens externally on 80 and forwards to Pod/container on 8080 +apiVersion: v1 +kind: Service +metadata: + name: hello-world +spec: + selector: + app: hello-world + ports: + - port: 80 + protocol: TCP + targetPort: 8080 + diff --git a/Services/svc-lb.yml b/Services/svc-lb.yaml similarity index 100% rename from Services/svc-lb.yml rename to Services/svc-lb.yaml diff --git a/Services/svc-nodeport.yml b/Services/svc-nodeport.yaml similarity index 100% rename from Services/svc-nodeport.yml rename to Services/svc-nodeport.yaml diff --git a/recommended.yaml b/recommended.yaml new file mode 100644 index 0000000..5bc4004 --- /dev/null +++ b/recommended.yaml @@ -0,0 +1,303 @@ +# Copyright 2017 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +kind: Namespace +metadata: + name: kubernetes-dashboard + +--- + +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard + namespace: kubernetes-dashboard + +--- + +kind: Service +apiVersion: v1 +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard + namespace: kubernetes-dashboard +spec: + ports: + - port: 443 + targetPort: 8443 + selector: + k8s-app: kubernetes-dashboard + +--- + +apiVersion: v1 +kind: Secret +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard-certs + namespace: kubernetes-dashboard +type: Opaque + +--- + +apiVersion: v1 +kind: Secret +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard-csrf + namespace: kubernetes-dashboard +type: Opaque +data: + csrf: "" + +--- + +apiVersion: v1 +kind: Secret +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard-key-holder + namespace: kubernetes-dashboard +type: Opaque + +--- + +kind: ConfigMap +apiVersion: v1 +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard-settings + namespace: kubernetes-dashboard + +--- + +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard + namespace: kubernetes-dashboard +rules: + # Allow Dashboard to get, update and delete Dashboard exclusive secrets. + - apiGroups: [""] + resources: ["secrets"] + resourceNames: ["kubernetes-dashboard-key-holder", "kubernetes-dashboard-certs", "kubernetes-dashboard-csrf"] + verbs: ["get", "update", "delete"] + # Allow Dashboard to get and update 'kubernetes-dashboard-settings' config map. + - apiGroups: [""] + resources: ["configmaps"] + resourceNames: ["kubernetes-dashboard-settings"] + verbs: ["get", "update"] + # Allow Dashboard to get metrics. + - apiGroups: [""] + resources: ["services"] + resourceNames: ["heapster", "dashboard-metrics-scraper"] + verbs: ["proxy"] + - apiGroups: [""] + resources: ["services/proxy"] + resourceNames: ["heapster", "http:heapster:", "https:heapster:", "dashboard-metrics-scraper", "http:dashboard-metrics-scraper"] + verbs: ["get"] + +--- + +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard +rules: + # Allow Metrics Scraper to get metrics from the Metrics server + - apiGroups: ["metrics.k8s.io"] + resources: ["pods", "nodes"] + verbs: ["get", "list", "watch"] + +--- + +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard + namespace: kubernetes-dashboard +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: kubernetes-dashboard +subjects: + - kind: ServiceAccount + name: kubernetes-dashboard + namespace: kubernetes-dashboard + +--- + +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: kubernetes-dashboard +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: kubernetes-dashboard +subjects: + - kind: ServiceAccount + name: kubernetes-dashboard + namespace: kubernetes-dashboard + +--- + +kind: Deployment +apiVersion: apps/v1 +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard + namespace: kubernetes-dashboard +spec: + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + k8s-app: kubernetes-dashboard + template: + metadata: + labels: + k8s-app: kubernetes-dashboard + spec: + containers: + - name: kubernetes-dashboard + image: kubernetesui/dashboard:v2.4.0 + imagePullPolicy: Always + ports: + - containerPort: 8443 + protocol: TCP + args: + - --auto-generate-certificates + - --namespace=kubernetes-dashboard + # Uncomment the following line to manually specify Kubernetes API server Host + # If not specified, Dashboard will attempt to auto discover the API server and connect + # to it. Uncomment only if the default does not work. + # - --apiserver-host=http://my-address:port + volumeMounts: + - name: kubernetes-dashboard-certs + mountPath: /certs + # Create on-disk volume to store exec logs + - mountPath: /tmp + name: tmp-volume + livenessProbe: + httpGet: + scheme: HTTPS + path: / + port: 8443 + initialDelaySeconds: 30 + timeoutSeconds: 30 + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + runAsUser: 1001 + runAsGroup: 2001 + volumes: + - name: kubernetes-dashboard-certs + secret: + secretName: kubernetes-dashboard-certs + - name: tmp-volume + emptyDir: {} + serviceAccountName: kubernetes-dashboard + nodeSelector: + "kubernetes.io/os": linux + # Comment the following tolerations if Dashboard must not be deployed on master + tolerations: + - key: node-role.kubernetes.io/master + effect: NoSchedule + +--- + +kind: Service +apiVersion: v1 +metadata: + labels: + k8s-app: dashboard-metrics-scraper + name: dashboard-metrics-scraper + namespace: kubernetes-dashboard +spec: + ports: + - port: 8000 + targetPort: 8000 + selector: + k8s-app: dashboard-metrics-scraper + +--- + +kind: Deployment +apiVersion: apps/v1 +metadata: + labels: + k8s-app: dashboard-metrics-scraper + name: dashboard-metrics-scraper + namespace: kubernetes-dashboard +spec: + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + k8s-app: dashboard-metrics-scraper + template: + metadata: + labels: + k8s-app: dashboard-metrics-scraper + spec: + securityContext: + seccompProfile: + type: RuntimeDefault + containers: + - name: dashboard-metrics-scraper + image: kubernetesui/metrics-scraper:v1.0.7 + ports: + - containerPort: 8000 + protocol: TCP + livenessProbe: + httpGet: + scheme: HTTP + path: / + port: 8000 + initialDelaySeconds: 30 + timeoutSeconds: 30 + volumeMounts: + - mountPath: /tmp + name: tmp-volume + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + runAsUser: 1001 + runAsGroup: 2001 + serviceAccountName: kubernetes-dashboard + nodeSelector: + "kubernetes.io/os": linux + # Comment the following tolerations if Dashboard must not be deployed on master + tolerations: + - key: node-role.kubernetes.io/master + effect: NoSchedule + volumes: + - name: tmp-volume + emptyDir: {}