-
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 #11
Open
Script1988
wants to merge
2
commits into
mate-academy:main
Choose a base branch
from
Script1988:develop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Solution #11
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: pods-lister | ||
namespace: todoapp | ||
|
||
--- | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: pods-lister | ||
namespace: todoapp | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods"] | ||
verbs: ["list"] | ||
|
||
--- | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: pods-lister-binging | ||
namespace: todoapp | ||
subjects: | ||
- kind: ServiceAccount | ||
name: pods-lister | ||
roleRef: | ||
kind: Role | ||
name: pods-lister | ||
apiGroup: rbac.authorization.k8s.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,14 @@ | ||
# Django ToDo list | ||
|
||
This is a todo list web application with basic features of most web apps, i.e., accounts/login, API, and interactive UI. To do this task, you will need: | ||
|
||
- CSS | [Skeleton](http://getskeleton.com/) | ||
- JS | [jQuery](https://jquery.com/) | ||
|
||
## Explore | ||
|
||
Try it out by installing the requirements (the following commands work only with Python 3.8 and higher, due to Django 4): | ||
|
||
``` | ||
pip install -r requirements.txt | ||
``` | ||
|
||
Create a database schema: | ||
|
||
``` | ||
python manage.py migrate | ||
``` | ||
|
||
And then start the server (default is http://localhost:8000): | ||
|
||
``` | ||
python manage.py runserver | ||
``` | ||
|
||
Now you can browse the [API](http://localhost:8000/api/) or start on the [landing page](http://localhost:8000/). | ||
|
||
## Task | ||
|
||
1. Fork this repository. | ||
1. Use `kind` to spin up a cluster from a `cluster.yml` configuration file. | ||
1. Create a manifest named `rbac` inside a `security` directory | ||
1. `rbac` manifest requirements: | ||
1. File should containa `ServiceAccount` definition | ||
1. File should contain a `Role` definition | ||
1. Role should allow to list secrets | ||
1. File should contain a `RoleBinding` definition | ||
1. RoleBinding should bind the `Role` to the `ServiceAccount` | ||
1. Use newly created `ServiceAccount` should be used by the `Deployment` in the `deployment` manifest | ||
1. Execute a curl command to list secrets from the `Deployment` pod to list secrets | ||
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. | ||
## Validation changes | ||
1. Run `bootstrap.sh` | ||
2. Use `kubectl get pods -n todoapp` | ||
3. Use `kubectl exec POD-NAME -it -n todoapp -- sh`, where POD-NAME is a name of your pod (NAME column). | ||
The command should look like `kubectl exec todoapp-9f575cc76-7vplb -it -n todoapp -- sh` | ||
4. Use `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/pods` to get a response | ||
|
||
![Result photo](rbac.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
According to the task description, this role should have access to secret