diff --git a/k8s_manifests/cron.yaml b/k8s_manifests/cron.yaml new file mode 100644 index 0000000..bb55b6a --- /dev/null +++ b/k8s_manifests/cron.yaml @@ -0,0 +1,15 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: example-cronjob +spec: + schedule: "*/5 * * * *" + jobTemplate: + spec: + template: + spec: + containers: + - name: job-container + image: your-image:tag + command: ["echo", "Hello, Kubernetes CronJob!"] + restartPolicy: OnFailure diff --git a/k8s_manifests/daemonset.yaml b/k8s_manifests/daemonset.yaml new file mode 100644 index 0000000..e5bbf73 --- /dev/null +++ b/k8s_manifests/daemonset.yaml @@ -0,0 +1,16 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: example-daemonset +spec: + selector: + matchLabels: + app: my-app + template: + metadata: + labels: + app: my-app + spec: + containers: + - name: my-app-container + image: your-image:tag diff --git a/k8s_manifests/full_stack_lb.yaml b/k8s_manifests/full_stack_lb.yaml index 1fe6ed5..609c75d 100644 --- a/k8s_manifests/full_stack_lb.yaml +++ b/k8s_manifests/full_stack_lb.yaml @@ -5,11 +5,12 @@ metadata: name: mainlb namespace: workshop annotations: + alb.ingress.kubernetes.io/group.name: demo-lb alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/target-type: ip #Uncommnt below to enable https, generate certificate from AWS ACM - # alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]' - # alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:region:account-id:certificate/certificate-id + alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]' + alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:us-west-2:120717539064:certificate/befc6ed9-44ae-41a1-ba96-0d562a369f64 spec: ingressClassName: alb rules: @@ -23,6 +24,13 @@ spec: name: api port: number: 8080 + - path: /v2/api + pathType: Prefix + backend: + service: + name: apiv2 + port: + number: 8080 - path: / pathType: Prefix backend: diff --git a/k8s_manifests/hpa.yaml b/k8s_manifests/hpa.yaml new file mode 100644 index 0000000..b4b18b0 --- /dev/null +++ b/k8s_manifests/hpa.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: autoscaling/v1 +kind: HorizontalPodAutoscaler +metadata: + name: api + namespace: shepherd +spec: + minReplicas: 2 + maxReplicas: 10 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: api + targetCPUUtilizationPercentage: 50 diff --git a/k8s_manifests/job.yaml b/k8s_manifests/job.yaml new file mode 100644 index 0000000..a907142 --- /dev/null +++ b/k8s_manifests/job.yaml @@ -0,0 +1,14 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: example-job +spec: + template: + metadata: + name: example-pod + spec: + containers: + - name: job-container + image: your-image:tag + command: ["echo", "Hello, Kubernetes Job!"] + restartPolicy: Never diff --git a/k8s_manifests/monitoring-lb.yaml b/k8s_manifests/monitoring-lb.yaml new file mode 100644 index 0000000..7e2fe74 --- /dev/null +++ b/k8s_manifests/monitoring-lb.yaml @@ -0,0 +1,27 @@ +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: monitoringlb + namespace: prometheus + annotations: + alb.ingress.kubernetes.io/group.name: demo-lb + alb.ingress.kubernetes.io/scheme: internet-facing + alb.ingress.kubernetes.io/target-type: ip + #Uncommnt below to enable https, generate certificate from AWS ACM + alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]' + alb.ingress.kubernetes.io/ssl-redirect: '443' + alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:us-west-2:120717539064:certificate/befc6ed9-44ae-41a1-ba96-0d562a369f64 +spec: + ingressClassName: alb + rules: + - host: monitor.sandipdas.in + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: prometheus-grafana + port: + number: 80 diff --git a/k8s_manifests/stateful.yaml b/k8s_manifests/stateful.yaml new file mode 100644 index 0000000..9f06231 --- /dev/null +++ b/k8s_manifests/stateful.yaml @@ -0,0 +1,28 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: example-statefulset +spec: + replicas: 3 + serviceName: my-stateful-service + selector: + matchLabels: + app: my-app + template: + metadata: + labels: + app: my-app + spec: + containers: + - name: my-app-container + image: your-image:tag + ports: + - containerPort: 80 + volumeClaimTemplates: + - metadata: + name: data + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 1Gi diff --git a/kustomize/myapp/kustomization.yaml b/kustomize/myapp/kustomization.yaml new file mode 100644 index 0000000..075335a --- /dev/null +++ b/kustomize/myapp/kustomization.yaml @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - deployment.yaml + - service.yaml + +configMapGenerator: + - name: myapp-config + files: + - config.properties diff --git a/kustomize/nginx/base/deployment.yaml b/kustomize/nginx/base/deployment.yaml new file mode 100644 index 0000000..3317bd5 --- /dev/null +++ b/kustomize/nginx/base/deployment.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + replicas: 2 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 80 diff --git a/kustomize/nginx/base/kustomization.yaml b/kustomize/nginx/base/kustomization.yaml new file mode 100644 index 0000000..a33121c --- /dev/null +++ b/kustomize/nginx/base/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - deployment.yaml + - service.yaml diff --git a/kustomize/nginx/base/service.yaml b/kustomize/nginx/base/service.yaml new file mode 100644 index 0000000..398ce13 --- /dev/null +++ b/kustomize/nginx/base/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: nginx-service +spec: + selector: + app: nginx + ports: + - protocol: TCP + port: 80 + targetPort: 80 + type: LoadBalancer diff --git a/kustomize/nginx/overlays/dev/dev-patch.yaml b/kustomize/nginx/overlays/dev/dev-patch.yaml new file mode 100644 index 0000000..1d2a7b9 --- /dev/null +++ b/kustomize/nginx/overlays/dev/dev-patch.yaml @@ -0,0 +1,6 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + replicas: 1 # Reducing the number of replicas for development diff --git a/kustomize/nginx/overlays/dev/kustomization.yaml b/kustomize/nginx/overlays/dev/kustomization.yaml new file mode 100644 index 0000000..09c936c --- /dev/null +++ b/kustomize/nginx/overlays/dev/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +bases: + - ../../base +patchesStrategicMerge: + - dev-patch.yaml + + diff --git a/kustomize/nginx/overlays/prod/kustomization.yaml b/kustomize/nginx/overlays/prod/kustomization.yaml new file mode 100644 index 0000000..d5bc03e --- /dev/null +++ b/kustomize/nginx/overlays/prod/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +bases: + - ../../base +patchesStrategicMerge: + - prod-patch.yaml + + diff --git a/kustomize/nginx/overlays/prod/prod-patch.yaml b/kustomize/nginx/overlays/prod/prod-patch.yaml new file mode 100644 index 0000000..ec845bd --- /dev/null +++ b/kustomize/nginx/overlays/prod/prod-patch.yaml @@ -0,0 +1,6 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + replicas: 10 # Reducing the number of replicas for development diff --git a/kustomize/nginx/overlays/staging/kustomization.yaml b/kustomize/nginx/overlays/staging/kustomization.yaml new file mode 100644 index 0000000..2c499df --- /dev/null +++ b/kustomize/nginx/overlays/staging/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +bases: + - ../../base +patchesStrategicMerge: + - staging-patch.yaml + + diff --git a/kustomize/nginx/overlays/staging/staging-patch.yaml b/kustomize/nginx/overlays/staging/staging-patch.yaml new file mode 100644 index 0000000..5c57698 --- /dev/null +++ b/kustomize/nginx/overlays/staging/staging-patch.yaml @@ -0,0 +1,6 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + replicas: 2 # Reducing the number of replicas for development diff --git a/load_test/alb-ingress.yaml b/load_test/alb-ingress.yaml new file mode 100644 index 0000000..1726c05 --- /dev/null +++ b/load_test/alb-ingress.yaml @@ -0,0 +1,20 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + alb.ingress.kubernetes.io/scheme: internet-facing + alb.ingress.kubernetes.io/target-type: ip + kubernetes.io/ingress.class: alb + alb.ingress.kubernetes.io/inbound-cidrs: 183.82.98.176/32,103.252.147.189/32,103.87.143.171/32 + finalizers: + - ingress.k8s.aws/resources + labels: + app: ingress + name: ingress-locust-dashboard + namespace: workshop +spec: + defaultBackend: + service: + name: awsblog-locust + port: + number: 8089 \ No newline at end of file diff --git a/load_test/locustfile.py b/load_test/locustfile.py new file mode 100644 index 0000000..43dc0a8 --- /dev/null +++ b/load_test/locustfile.py @@ -0,0 +1,10 @@ +from locust import HttpUser, task, between + +default_headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36'} + +class WebsiteUser(HttpUser): + wait_time = between(1, 5) + + @task(1) + def get_index(self): + self.client.get("/", headers=default_headers) diff --git a/three_tier_eks_project.code-workspace b/three_tier_eks_project.code-workspace index 362d7c2..b0b5979 100644 --- a/three_tier_eks_project.code-workspace +++ b/three_tier_eks_project.code-workspace @@ -2,6 +2,9 @@ "folders": [ { "path": "." + }, + { + "path": "../demo-helm" } ] } \ No newline at end of file