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

solution #9

Open
wants to merge 2 commits 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
35 changes: 35 additions & 0 deletions .infrastructure/security/rbac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: secrets-reader
namespace: todoapp

---

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

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: secrets-reader-binding
namespace: todoapp
subjects:
- kind: ServiceAccount
name: secrets-reader
roleRef:
kind: Role
name: secrets-reader
apiGroup: rbac.authorization.k8s.io



14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,17 @@ Now you can browse the [API](http://localhost:8000/api/) or start on the [landin
1. Make a screenshot of the output and attach it to the PR
1. `README.md` should have instructuions on how to validate the changes
1. Create PR with your changes and attach it for validation on a platform.

In order to start the application, first you should create the cluster
kind create cluster --config cluster.yml
Then, start the next script
./bootstrap.sh

Apply rbac-manifest:
$kubectl apply -f .infrastructure/security/rbac.yml
In order to check rbac-configurations, exucute the next commands
$kubectl exec <pod-name> -it -n todoapp -- sh
Create the next env valueses inside pod
APISERVER=https://kubernetes.default.svc SERVICEACCOUNT=/var/run/secrets/kubernetes.io/serviceaccount TOKEN=$(cat ${SERVICEACCOUNT}/token) CACERT=${SERVICEACCOUNT}/ca.crt
Then execute the command
curl --cacert ${CACERT} --header "Authorization: Bearer ${TOKEN}" -X GET ${APISERVER}/api/v1/namespaces/todoapp/secrets
Binary file added screenshot_2024-05-08 131532.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.