first commit
This commit is contained in:
commit
a615e8a1f9
2 changed files with 197 additions and 0 deletions
56
README.md
Normal file
56
README.md
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
**Project**: inftools-cn
|
||||
|
||||
**Purpose**: This repository contains a small helper container image and scripts to build and run a debugging/admin container for working with Docker and lightweight Kubernetes (k3d). The image includes `kubectl`, the Docker CLI, and `k3d` so you can create and administer a local k3d cluster from inside the container.
|
||||
|
||||
**Key Files**:
|
||||
- `Dockerfile`: Builds the helper image (Debian Bookworm) with `kubectl`, `k3d`, and the Docker CLI.
|
||||
- `build.sh`: Ensures the `inftools-cn:latest` image exists, creates a user Docker network (`student-net`) if missing, and (when needed) runs `k3d cluster create mycluster` inside the helper container. It also edits the kubeconfig stored in the `mykube` Docker volume so the cluster API uses the load-balancer node.
|
||||
- `run.sh`: Launches an interactive shell in the helper container, mounting the Docker socket and the `mykube` volume.
|
||||
|
||||
**Image / Resources**:
|
||||
- Image name: `inftools-cn:latest`
|
||||
- Docker network used: `student-net`
|
||||
- Docker volume used for kubeconfig: `mykube`
|
||||
|
||||
**Requirements**:
|
||||
- Docker must be installed and the user must be able to access the Docker daemon (the scripts bind-mount `/var/run/docker.sock`).
|
||||
- Host can run containers and create networks/volumes.
|
||||
|
||||
**Quick Usage**:
|
||||
|
||||
- Build and create the k3d cluster (recommended):
|
||||
|
||||
```bash
|
||||
./build.sh
|
||||
```
|
||||
|
||||
- Start an interactive shell inside the helper container (uses the pre-built `inftools-cn:latest` image):
|
||||
|
||||
```bash
|
||||
./run.sh
|
||||
```
|
||||
|
||||
see [this demo](http://ascii.headshed.dev/a/dbfdZXIGo2wrvwn9ePsf9TFPs) of `build.sh` and `run.sh` on a debian bookworm OS
|
||||
|
||||
<script src="http://ascii.headshed.dev/a/dbfdZXIGo2wrvwn9ePsf9TFPs.js" id="asciicast-dbfdZXIGo2wrvwn9ePsf9TFPs" async="true"></script>
|
||||
|
||||
- Manual docker build/run (if you prefer):
|
||||
|
||||
```bash
|
||||
docker build -t inftools-cn:latest .
|
||||
docker network create student-net # if not present
|
||||
docker run --rm -it --network student-net -v /var/run/docker.sock:/var/run/docker.sock -v mykube:/root/.kube inftools-cn:latest bash
|
||||
```
|
||||
|
||||
**What `build.sh` does (summary)**:
|
||||
- Ensures the `inftools-cn:latest` image exists (builds it from `Dockerfile` if missing).
|
||||
- Creates `student-net` Docker network if it doesn't exist.
|
||||
- Runs the `k3d cluster create mycluster` command inside the helper container, captures the output to find the load-balancer node, and updates the kubeconfig in the `mykube` volume so the cluster API endpoint points to the LB node on port `6443`.
|
||||
|
||||
**Security notes**:
|
||||
- The container mounts the host Docker socket (`/var/run/docker.sock`) into the container which grants the container broad control over the host Docker daemon. Only run this in trusted environments.
|
||||
|
||||
**License**:
|
||||
- This project is licensed under the GNU General Public License v3.0 (GPL-3.0).
|
||||
- See the `LICENSE` file in this repository for the full license text.
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue