Skip to content

Commit

Permalink
kustomize example
Browse files Browse the repository at this point in the history
  • Loading branch information
sd031 committed Dec 16, 2023
1 parent 157385c commit e922199
Show file tree
Hide file tree
Showing 20 changed files with 245 additions and 2 deletions.
15 changes: 15 additions & 0 deletions k8s_manifests/cron.yaml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions k8s_manifests/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 10 additions & 2 deletions k8s_manifests/full_stack_lb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions k8s_manifests/hpa.yaml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions k8s_manifests/job.yaml
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions k8s_manifests/monitoring-lb.yaml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions k8s_manifests/stateful.yaml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions kustomize/myapp/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml

configMapGenerator:
- name: myapp-config
files:
- config.properties
19 changes: 19 additions & 0 deletions kustomize/nginx/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions kustomize/nginx/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml
12 changes: 12 additions & 0 deletions kustomize/nginx/base/service.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions kustomize/nginx/overlays/dev/dev-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 1 # Reducing the number of replicas for development
8 changes: 8 additions & 0 deletions kustomize/nginx/overlays/dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../../base
patchesStrategicMerge:
- dev-patch.yaml


8 changes: 8 additions & 0 deletions kustomize/nginx/overlays/prod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../../base
patchesStrategicMerge:
- prod-patch.yaml


6 changes: 6 additions & 0 deletions kustomize/nginx/overlays/prod/prod-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 10 # Reducing the number of replicas for development
8 changes: 8 additions & 0 deletions kustomize/nginx/overlays/staging/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../../base
patchesStrategicMerge:
- staging-patch.yaml


6 changes: 6 additions & 0 deletions kustomize/nginx/overlays/staging/staging-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2 # Reducing the number of replicas for development
20 changes: 20 additions & 0 deletions load_test/alb-ingress.yaml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions load_test/locustfile.py
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions three_tier_eks_project.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"folders": [
{
"path": "."
},
{
"path": "../demo-helm"
}
]
}

0 comments on commit e922199

Please sign in to comment.