From d15a83a517d23e9b13e5dc99ed54c3b024ac6743 Mon Sep 17 00:00:00 2001 From: Tung Leo Date: Sun, 17 Mar 2024 11:47:08 +0700 Subject: [PATCH 1/3] doc: init the kubectl usage --- docs/usage/README.md | 4 ++++ docs/usage/ansible_usage.md | 11 ++++++++++- docs/usage/kubectl_usage.md | 36 +++++++++++++++++++++++++++++++++++ docs/usage/python_usage.md | 11 ++++++++++- docs/usage/terraform_usage.md | 11 ++++++++++- 5 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 docs/usage/kubectl_usage.md diff --git a/docs/usage/README.md b/docs/usage/README.md index f46d0eb..91e3da8 100644 --- a/docs/usage/README.md +++ b/docs/usage/README.md @@ -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) diff --git a/docs/usage/ansible_usage.md b/docs/usage/ansible_usage.md index 9a8d8d8..ab6312c 100644 --- a/docs/usage/ansible_usage.md +++ b/docs/usage/ansible_usage.md @@ -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 + +- +- + +## 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 diff --git a/docs/usage/kubectl_usage.md b/docs/usage/kubectl_usage.md new file mode 100644 index 0000000..182b7db --- /dev/null +++ b/docs/usage/kubectl_usage.md @@ -0,0 +1,36 @@ +# Use kubectl in the devops-toolkit + +## Kubernetes document + +Some document to help you start with kubernetes (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 inside container + +```bash +docker run --rm --network host -it devops-toolkit:latest +# You now in the container terminal + +# TODO +``` + +## Use case 2: Use kubeconfig from the host + +```bash +# Given that we have code somewhere in you machine +docker run --rm -v "$(pwd)":/root/kubectl_workspace --network host -it devops-toolkit:latest +# Run the kubectl code as usual +# TODO +``` + +## Troubleshooting + +- For any issues, check [this reference](../troubleshooting/TROUBLESHOOTING.md) diff --git a/docs/usage/python_usage.md b/docs/usage/python_usage.md index aa3893a..4961ffd 100644 --- a/docs/usage/python_usage.md +++ b/docs/usage/python_usage.md @@ -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 + +- +- + +## 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 diff --git a/docs/usage/terraform_usage.md b/docs/usage/terraform_usage.md index aa757fb..6e8e1f6 100644 --- a/docs/usage/terraform_usage.md +++ b/docs/usage/terraform_usage.md @@ -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 + +- +- + +## 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 From f1ddd9043003a09122a879caeafa08dff477c8de Mon Sep 17 00:00:00 2001 From: Tung Leo Date: Sun, 17 Mar 2024 12:28:14 +0700 Subject: [PATCH 2/3] doc: update the kubectl usage --- docs/usage/kubectl_usage.md | 38 ++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/docs/usage/kubectl_usage.md b/docs/usage/kubectl_usage.md index 182b7db..b220c51 100644 --- a/docs/usage/kubectl_usage.md +++ b/docs/usage/kubectl_usage.md @@ -13,22 +13,42 @@ To use the existing container instead of creating one, use `docker exec` command docker exec -it my_devops_toolkit /bin/bash ``` -## Use case 1: Use kubeconfig inside container +## 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 devops-toolkit:latest -# You now in the container terminal +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 -# TODO ``` -## Use case 2: Use kubeconfig from the host +Sample Result ```bash -# Given that we have code somewhere in you machine -docker run --rm -v "$(pwd)":/root/kubectl_workspace --network host -it devops-toolkit:latest -# Run the kubectl code as usual -# TODO +➜ ~ 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 From dfeefc35bbe9d5c1af3f835715e7801c634a0db2 Mon Sep 17 00:00:00 2001 From: Tung Leo Date: Sun, 17 Mar 2024 12:29:21 +0700 Subject: [PATCH 3/3] doc: update the kubectl usage.v1 --- docs/usage/kubectl_usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage/kubectl_usage.md b/docs/usage/kubectl_usage.md index b220c51..aba8a39 100644 --- a/docs/usage/kubectl_usage.md +++ b/docs/usage/kubectl_usage.md @@ -30,7 +30,7 @@ kubectl apply -f https://k8s.io/examples/application/deployment.yaml kubectl get pods -w # View the deployment kubectl get deployment - +# More command as per your need... ``` Sample Result