Skip to content

Commit

Permalink
doc: add the kubectl usage (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
tungbq authored Mar 17, 2024
2 parents 623b162 + dfeefc3 commit 937f5f5
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 3 deletions.
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

0 comments on commit 937f5f5

Please sign in to comment.