From c7be60e1b773856fadf1f27a7597e5bc58decf20 Mon Sep 17 00:00:00 2001 From: kevencript Date: Tue, 21 Mar 2023 14:32:09 -0300 Subject: [PATCH] feat: :sparkles: Namespace: Defining namespace for each manifest Here we are specifying the "namespace" field into the menifests accordingly to it purpose. --- k8s/configmap-env.yaml | 1 + k8s/configmap-injection.yaml | 1 + k8s/deployment.yaml | 1 + k8s/hpa.yaml | 1 + k8s/ingress.yaml | 1 + k8s/mysql-headless-svc.yaml | 1 + k8s/mysql-secret.yaml | 1 + k8s/namespace.yaml | 4 ---- k8s/namespaces/deployment-example.yaml | 22 ++++++++++++++++++++++ k8s/persistent-volume-claim.yaml | 1 + k8s/secret.yaml | 1 + k8s/service.yaml | 1 + k8s/statefulset.yaml | 1 + 13 files changed, 33 insertions(+), 4 deletions(-) delete mode 100644 k8s/namespace.yaml create mode 100644 k8s/namespaces/deployment-example.yaml diff --git a/k8s/configmap-env.yaml b/k8s/configmap-env.yaml index 3393da2..d0ed1c2 100644 --- a/k8s/configmap-env.yaml +++ b/k8s/configmap-env.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: configmap-app-env + namespace: server data: NAME: "Gabriel Costa" AGE: "23" diff --git a/k8s/configmap-injection.yaml b/k8s/configmap-injection.yaml index 187febb..394e5fc 100644 --- a/k8s/configmap-injection.yaml +++ b/k8s/configmap-injection.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: configmap-app-injection + namespace: server data: config: | Gabriel, Fulano, Ciclano diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index 6aa6785..ae824a3 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -2,6 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: go-http-app + namespace: server labels: app: go-http-app tier: backend diff --git a/k8s/hpa.yaml b/k8s/hpa.yaml index e6941f4..dd233d4 100644 --- a/k8s/hpa.yaml +++ b/k8s/hpa.yaml @@ -2,6 +2,7 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: go-http-app-hpa + namespace: server spec: scaleTargetRef: apiVersion: apps/v1 diff --git a/k8s/ingress.yaml b/k8s/ingress.yaml index 583dd07..dc25ca2 100644 --- a/k8s/ingress.yaml +++ b/k8s/ingress.yaml @@ -2,6 +2,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: nginx-ingress + namespace: server annotations: # Define which ingress class this manifest will use kubernetes.io/ingress.class: "nginx" diff --git a/k8s/mysql-headless-svc.yaml b/k8s/mysql-headless-svc.yaml index c74265c..eb8303f 100644 --- a/k8s/mysql-headless-svc.yaml +++ b/k8s/mysql-headless-svc.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: mysql-headless + namespace: database spec: clusterIP: None selector: diff --git a/k8s/mysql-secret.yaml b/k8s/mysql-secret.yaml index 9b5e3eb..e96e96c 100644 --- a/k8s/mysql-secret.yaml +++ b/k8s/mysql-secret.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Secret metadata: name: mysql-root-password + namespace: database type: Opaque data: password: YWRtaW4K diff --git a/k8s/namespace.yaml b/k8s/namespace.yaml deleted file mode 100644 index d029421..0000000 --- a/k8s/namespace.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: k8s-fundamentals diff --git a/k8s/namespaces/deployment-example.yaml b/k8s/namespaces/deployment-example.yaml new file mode 100644 index 0000000..72d6f97 --- /dev/null +++ b/k8s/namespaces/deployment-example.yaml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: server +spec: + selector: + matchLabels: + app: server + template: + metadata: + labels: + app: server + spec: + containers: + - name: server + image: wesleywillians/hello-express + resources: + limits: + memory: "128Mi" + cpu: "500m" + ports: + - containerPort: 3000 diff --git a/k8s/persistent-volume-claim.yaml b/k8s/persistent-volume-claim.yaml index 873fe0f..84df982 100644 --- a/k8s/persistent-volume-claim.yaml +++ b/k8s/persistent-volume-claim.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: example-pvc + namespace: database spec: resources: requests: diff --git a/k8s/secret.yaml b/k8s/secret.yaml index ec2bb93..1f8fc99 100644 --- a/k8s/secret.yaml +++ b/k8s/secret.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Secret metadata: name: secret-app + namespace: server type: Opaque data: USER: Z2FicmllbAo= diff --git a/k8s/service.yaml b/k8s/service.yaml index 8cf9e8d..ff7653c 100644 --- a/k8s/service.yaml +++ b/k8s/service.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: go-http-app-service + namespace: server labels: app: go-http-app tier: backend diff --git a/k8s/statefulset.yaml b/k8s/statefulset.yaml index 87464b8..793104b 100644 --- a/k8s/statefulset.yaml +++ b/k8s/statefulset.yaml @@ -2,6 +2,7 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: mysql-example + namespace: database spec: selector: matchLabels: