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

doc: add the kubectl usage #116

Merged
merged 3 commits into from
Mar 17, 2024
Merged
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
4 changes: 4 additions & 0 deletions docs/usage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ This guide us how to use the `devops-toolkit` with serveral usecases

- Check [**terraform_usage**](./terraform_usage.md)

## Kubectl

- Check [**kubectl_usage**](./kubectl_usage.md)

## Troubleshooting

- For any issues, check [this document](../troubleshooting/TROUBLESHOOTING.md)
11 changes: 10 additions & 1 deletion docs/usage/ansible_usage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Use ansible in the devops-toolkit

To use the existing container isntead of creating one, use `docker exec` command instead of `docker run`
## Ansible document

Some document to help you start with ansible

- <https://github.com/tungbq/devops-basic/tree/main/topics/ansible>
- <https://www.ansible.com/>

## Note

To use the existing container instead of creating one, use `docker exec` command instead of `docker run`

```bash
docker exec -it my_devops_toolkit /bin/bash
Expand Down
56 changes: 56 additions & 0 deletions docs/usage/kubectl_usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Use kubectl in the devops-toolkit

## Kubernetes document

Some document to help you start with kubernetes (k8s)

- <https://kubernetes.io/docs/home/>
- <https://github.com/tungbq/devops-basic/tree/main/topics/k8s>

To use the existing container instead of creating one, use `docker exec` command instead of `docker run`

```bash
docker exec -it my_devops_toolkit /bin/bash
```

## Use case 1: Use kubeconfig from the host

Mount the `.kube/config` file from the host to container

```bash
docker run --rm --network host -it -v ~/.kube/config:/root/.kube/config devops-toolkit:latest
###############################################
# Now we are in the docker container terminal #
###############################################
kubectl get nodes

# Deploy application
kubectl apply -f https://k8s.io/examples/application/deployment.yaml
# View the pod
kubectl get pods -w
# View the deployment
kubectl get deployment
# More command as per your need...
```

Sample Result

```bash
➜ ~ docker run --rm --network host -it -v ~/.kube/config:/root/.kube/config devops-toolkit:latest
root@docker-desktop:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
kind-control-plane Ready control-plane 21m v1.29.2
root@docker-desktop:~# kubectl apply -f https://k8s.io/examples/application/deployment.yaml
deployment.apps/nginx-deployment unchanged
root@docker-desktop:~# kubectl get pods -w
NAME READY STATUS RESTARTS AGE
nginx-deployment-86dcfdf4c6-c2cfp 1/1 Running 0 99s
nginx-deployment-86dcfdf4c6-w4vp7 1/1 Running 0 99s
root@docker-desktop:~# kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
nginx-deployment 2/2 2 2 115s
```

## Troubleshooting

- For any issues, check [this reference](../troubleshooting/TROUBLESHOOTING.md)
11 changes: 10 additions & 1 deletion docs/usage/python_usage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Use python in the devops-toolkit

To use the existing container isntead of creating one, use `docker exec` command instead of `docker run`
## Python document

Some document to help you start with python

- <https://www.python.org/doc/>
- <https://github.com/tungbq/devops-basic/tree/main/topics/python>

## Note

To use the existing container instead of creating one, use `docker exec` command instead of `docker run`

```bash
# Given that we have 'my_devops_toolkit' start before
Expand Down
11 changes: 10 additions & 1 deletion docs/usage/terraform_usage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Use terraform in the devops-toolkit

To use the existing container isntead of creating one, use `docker exec` command instead of `docker run`
## Terraform document

Some document to help you start with terraform

- <https://developer.hashicorp.com/terraform>
- <https://github.com/tungbq/devops-basic/tree/main/topics/terraform>

## Note

To use the existing container instead of creating one, use `docker exec` command instead of `docker run`

```bash
docker exec -it my_devops_toolkit /bin/bash
Expand Down