|
@ -1,8 +1,61 @@ |
|
|
# Introduction to kubectl |
|
|
# Introduction to kubectl |
|
|
|
|
|
|
|
|
|
|
|
## Prerequisites |
|
|
|
|
|
|
|
|
|
|
|
For using this you must install the following tools: |
|
|
|
|
|
|
|
|
|
|
|
- Python |
|
|
|
|
|
- Pip |
|
|
|
|
|
- Kubectl |
|
|
|
|
|
- Openstack-Client |
|
|
|
|
|
|
|
|
|
|
|
### Python |
|
|
|
|
|
|
|
|
|
|
|
Install python and pip for your OS, if it is not installed. This is already done at the NetLab PCs. |
|
|
|
|
|
|
|
|
|
|
|
### Installing kubectl and arkade |
|
|
|
|
|
|
|
|
|
|
|
Run this in a **bash** terminal to download arkade and install kubectl: |
|
|
|
|
|
|
|
|
|
|
|
For windows you can use e.g. the **Git Bash** terminal. |
|
|
|
|
|
|
|
|
|
|
|
```bash |
|
|
|
|
|
curl -sLS https://dl.get-arkade.dev | sh |
|
|
|
|
|
arkade get kubectl |
|
|
|
|
|
# To load the path to the binary |
|
|
|
|
|
export PATH=$PATH:$HOME/.arkade/bin/ |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
With arkade you can also install other tools: ```arkade get``` to see all possibilities. |
|
|
|
|
|
|
|
|
|
|
|
### Openstack Client |
|
|
|
|
|
|
|
|
|
|
|
To install the Openstack client and the magnum package: |
|
|
|
|
|
|
|
|
|
|
|
If you are using Windows, you must start the bash terminal with **Administrator** privileges! |
|
|
|
|
|
|
|
|
|
|
|
```bash |
|
|
|
|
|
pip3 install openstackclient python-magnumclient |
|
|
|
|
|
# Download the Openstack RC File from your Openstack account |
|
|
|
|
|
# Load the file |
|
|
|
|
|
source {USERNAME}-openrc.sh |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
### Download the kubeconfig |
|
|
|
|
|
|
|
|
|
|
|
Download the kubeconfig file for your cluster from OpenStack. |
|
|
|
|
|
|
|
|
|
|
|
```bash |
|
|
|
|
|
# Before using this, check if Openstack RC File is loaded! |
|
|
|
|
|
openstack coe cluster config {CLUSTER_NAME} |
|
|
|
|
|
# Then run the given command in terminal |
|
|
|
|
|
export ... |
|
|
|
|
|
# Now you are able to run kubectl commands at your Kubernetes cluster |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
## Deployment of the needed description in kubernetes |
|
|
## Deployment of the needed description in kubernetes |
|
|
|
|
|
|
|
|
These are two approaches to create the description in Kuberentes: |
|
|
|
|
|
|
|
|
These are two approaches to create the description in Kubernetes: |
|
|
|
|
|
|
|
|
```bash |
|
|
```bash |
|
|
# create a namespace |
|
|
# create a namespace |
|
@ -41,10 +94,10 @@ kubectl logs -n web-test deployment/nginx-deployment |
|
|
|
|
|
|
|
|
```bash |
|
|
```bash |
|
|
# scale up instances to 5 |
|
|
# scale up instances to 5 |
|
|
kubectl scale deployment/nginx-deployment --replicas=5 |
|
|
|
|
|
|
|
|
kubectl scale -n web-test deployment/nginx-deployment --replicas=5 |
|
|
|
|
|
|
|
|
# scale down instances again to 3 |
|
|
# scale down instances again to 3 |
|
|
kubectl scale deployment/nginx-deployment --replicas=3 |
|
|
|
|
|
|
|
|
kubectl scale -n web-test deployment/nginx-deployment --replicas=3 |
|
|
|
|
|
|
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|