-
Notifications
You must be signed in to change notification settings - Fork 34
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 #27
base: main
Are you sure you want to change the base?
Solution #27
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
kind: ServiceAccount | ||
apiVersion: v1 | ||
metadata: | ||
name: secrets-reader | ||
namespace: todoapp | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: secrets-reader-role | ||
namespace: todoapp | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods", "secrets"] | ||
verbs: ["list", "get"] | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: secret-reader-binding | ||
namespace: todoapp | ||
subjects: | ||
- kind: ServiceAccount | ||
name: secrets-reader | ||
roleRef: | ||
kind: Role | ||
name: secrets-reader-role | ||
apiGroup: rbac.authorization.k8s.io |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# RBAC for TodoApp | ||
|
||
## 1. Create a Kubernetes cluster: | ||
```bash | ||
kubectl create cluster --config cluster.yml | ||
``` | ||
|
||
## 2. Deploy the application and additional resources: | ||
```bash | ||
./bootstrap.sh | ||
``` | ||
|
||
## 3. Wait for 1-2 minutes for all pods to initialize. Once ready, verify the pod statuses: | ||
```bash | ||
kubectl get pods -n todoapp | ||
``` | ||
|
||
## 4. Connect to a pod: | ||
```bash | ||
kubectl exec <pod name> -it -n todoapp -- sh | ||
``` | ||
|
||
## 5. Set Up and Execute the cURL Command: | ||
```bash | ||
SERVICEACCOUNT=/var/run/secrets/kubernetes.io/serviceaccount | ||
APISERVER=https://kubernetes.default.svc | ||
TOKEN=$(cat ${SERVICEACCOUNT}/token) | ||
CACERT=${SERVICEACCOUNT}/ca.crt | ||
|
||
curl --cacert ${CACERT} --header "Authorization: Bearer ${TOKEN}" -X GET ${APISERVER}/api/v1/namespaces/todoapp/secrets | ||
``` | ||
|
||
## 6. Verify the Output. | ||
The response should include the details of the secrets in the todoapp namespace. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ kubectl apply -f .infrastructure/app/nodeport.yml | |
kubectl apply -f .infrastructure/app/hpa.yml | ||
kubectl apply -f .infrastructure/app/deployment.yml | ||
|
||
kubectl apply -f .infrastructure/security/rbac.yml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that the |
||
|
||
# Install Ingress Controller | ||
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The script installs the Ingress Controller using a URL. Ensure that the URL is correct and accessible. If there are any network restrictions, this might fail. |
||
# kubectl apply -f .infrastructure/ingress/ingress.yml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ingress configuration is commented out. If ingress is required for your application, make sure to uncomment this line and verify that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Ingress configuration is commented out. If your application requires Ingress, make sure to uncomment this line or apply the necessary Ingress configuration to ensure external access to your services. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script applies the RBAC configuration, which is crucial for setting up permissions. Ensure that the
rbac.yml
file is correctly configured to avoid permission issues.