semvec/pypi-packages huggingface dataset:
broentech 2.0.4
kubernetes client code
License: Apache license 2.0
Keywords: kubernetes,clusterinfo

- [PyKube](#pykube)
- [Usage](#usage)
    - [Build](#build)
        - [Bash](#bash)
        - [Powershell](#powershell)

# PyKube

The goal of this image is to be able to reach clusters and use their API's from a pod programmatically with python.
In order for the image to use the correct settings it has to be rebuilt everytime the cluster have been updated with:

    - access privileges
    - tokens
    - hosts
    - ~/.kube/config

If the cluster has been reset the image will have to be rebuilt because the tokens have been renewed.
To prevent using kubectl as a sidecar in a pod when accessing a local cluster, we just copy over the local settings and let python kubernetes lib use those.

# Usage

- Build
- Deploy
- exec
- manually call python code in dev. phase

## Build

In order to build the image correctly follow the instructions below (regular docker build / docker-compose build cannot be used due to needed args in the build process)

### Bash

```bash
docker build --no-cache -f aikpy/pykube/Dockerfile -t pykube:1 --build-arg KUBE_CONFIG="$(cat ~/.kube/config)" --build-arg API_TOKEN="$(kubectl describe secret default | grep -e '^token' | cut -f 2 -d ':' | tr -d ' \t')" --build-arg HOSTLIST="$(kubectl config view -o jsonpath='{range .clusters[*]}{.cluster.server}{","}{end}' | sed 's/,$/ /g')" aikpy/pykube
```

### Powershell

```powershell
docker build --no-cache -f .\aikpy\pykube\Dockerfile -t pykube:1 --build-arg KUBE_CONFIG="$(cat $env:USERPROFILE\.kube\config)" --build-arg API_TOKEN="$(kubectl describe secret default | findstr /B token | %{$_.split(':')[1]
} | %{$_ -replace ' ', ''})" --build-arg HOSTLIST="$(kubectl config view -o jsonpath='{range .clusters[*]}{.cluster.server}{\",\"}{end}' | %{$_ -replace ",$",''})" .\aikpy\pykube\
```