Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solved #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .infrastructure/app/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ spec:
selector:
matchLabels:
app: todoapp
replicas: 2
template:
metadata:
labels:
app: todoapp
spec:
serviceAccountName: secrets-reader
serviceAccountName: list-pods-sa
containers:
- name: todoapp
image: ikulyk404/todoapp:4.0.1
Expand Down
33 changes: 33 additions & 0 deletions .infrastructure/security/rbac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: list-pods-sa
namespace: todoapp

---

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: list-pods-role
namespace: todoapp
rules:
- apiGroups: [""]
resources: ["pods", "secrets"]
verbs: ["get", "list"]

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: list-pods-rb
namespace: todoapp
subjects:
- kind: ServiceAccount
name: list-pods-sa
namespace: todoapp
roleRef:
kind: Role
name: list-pods-role
apiGroup: rbac.authorization.k8s.io
12 changes: 12 additions & 0 deletions INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
In order to validate that the roles are applied correctly:

kubectl exec -it <pod-name> -- /bin/sh

TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)

curl -s -k \
-H "Authorization: Bearer $TOKEN" \
https://kubernetes.default.svc/api/v1/namespaces/$NAMESPACE/secrets


17 changes: 9 additions & 8 deletions bootstrap.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#!/bin/bash
kubectl apply -f .infrastructure/mysql/ns.yml
kubectl apply -f .infrastructure/mysql/configMap.yml
kubectl apply -f .infrastructure/mysql/secret.yml
kubectl apply -f .infrastructure/mysql/service.yml
kubectl apply -f .infrastructure/mysql/statefulSet.yml
# kubectl apply -f .infrastructure/mysql/ns.yml
# kubectl apply -f .infrastructure/mysql/configMap.yml
# kubectl apply -f .infrastructure/mysql/secret.yml
# kubectl apply -f .infrastructure/mysql/service.yml
# kubectl apply -f .infrastructure/mysql/statefulSet.yml
Comment on lines +2 to +6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are commented out, which means the MySQL resources will not be applied. Ensure this is intentional and that MySQL is either not needed or is managed separately.


kubectl apply -f .infrastructure/app/ns.yml
# kubectl apply -f .infrastructure/app/ns.yml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The namespace for the app is commented out. Make sure the namespace already exists or is created by another means before applying other resources.

kubectl apply -f .infrastructure/app/pv.yml
kubectl apply -f .infrastructure/app/pvc.yml
kubectl apply -f .infrastructure/app/secret.yml
kubectl apply -f .infrastructure/app/configMap.yml
kubectl apply -f .infrastructure/app/clusterIp.yml
kubectl apply -f .infrastructure/app/nodeport.yml
# kubectl apply -f .infrastructure/app/nodeport.yml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NodePort service is commented out. If external access to the application is needed, ensure that this is configured appropriately elsewhere.

kubectl apply -f .infrastructure/app/hpa.yml
kubectl apply -f .infrastructure/app/deployment.yml
kubectl apply -f .infrastructure/security/rbac.yml

# Install Ingress Controller
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
# kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
# kubectl apply -f .infrastructure/ingress/ingress.yml
Comment on lines +20 to 21

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ingress-related commands are commented out. If you require ingress for your application, make sure to uncomment these lines or manage ingress separately.

8 changes: 0 additions & 8 deletions cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ nodes:
hostPort: 443
protocol: TCP
# the two workers
- role: worker
extraMounts:
- hostPath: /tmp
containerPath: /data
- role: worker
extraMounts:
- hostPath: /tmp
containerPath: /data
- role: worker
extraMounts:
- hostPath: /tmp
Expand Down