Dropping Kali in your test space

k8s testing with kali linux

Setting up docker

Add User to Docker Group

After installing Docker, add your user to the Docker group to run Docker commands without sudo.

  1. Add User to Docker Group:

    sudo usermod -aG docker $USER
  2. Refresh Group Membership:

    newgrp docker
  3. Verify Group Membership:

    groups $USER

docker ps

This command lists running containers. We have nothing running as it's a new environment

CONTAINER ID   IMAGE    COMMAND    CREATED    STATUS    PORTS

docker run hello-world

The docker run hello-world command is a simple way to verify that Docker is installed and functioning correctly on your system.

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (arm64v8)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

start minikube

Download minikube for your architechture

Minikube is an open-source tool that enables you to run a single-node Kubernetes cluster locally on your machine. Minikube runs a Kubernetes cluster in a virtual machine (VM) on your computer, which allows developers to create and manage Kubernetes environments without needing a full-blown, multi-node cluster.

get nodes

describe node

Lets create a deployment file and service file for nginx

  • Deployment: A Deployment ensures that a specified number of identical Pods (boxes) are always running, updating them when needed.

  • Service: A Service provides a stable network address for accessing the Pods (boxes) and balances the load among them, even if the underlying Pods change.

nginx-deployment.yaml

nginx-service.yaml

Apply the configurations...

Verify the deployment and service...

At this point please find vulnerable images for the purpose of testing. Vulhub has a well updated docker repo.

https://hub.docker.com/explore - Dcoker official images

Getting deployments and services

Now lets get pods

Creating a kali dockerfile and pushing to docker hub

Here's what we're going to do to get kali pushed to our repo and then deployed

  1. Create the kali dockerfile

  2. Build the docker image

  3. Push that image to Docker Hub

  4. Deploy image to K8s

  5. Apply the deployment to K8s

Create the docker file

Build the docker image

Now lets push this to our docker hub repo (this could take a while)

We can also just run this container locally docker run -it sx0tt/kali-linux-tools2 /bin/bash

Once the push is finished lets create a deployment yaml for our image

Deploy the image to k8s

Last updated