Kubernetes_RFD
Multiple Kubernetes projects for all kinds of problems.
Prerequisites
You need to have a Kubernetes cluster available.
If you do not have one, you can virtualize with tools such as minikube in version v1.16.0 or higher. https://github.com/kubernetes/minikube
All the custom images that will be used in this repository have been generated by dockerfile or similar files from the following repository: https://github.com/JoseManuelPS/Docker_RFD
It is recommended to have a proprietary image repository such as Docker Registry or Nexus to facilitate the image management task.
ansible/basic:v1.0
This short tutorial explains in a simple way how to deploy an ansible laboratory based on https://github.com/JoseManuelPS/Docker_RFD ansible/basic.
Note: To mount volumes in minikube please use the following args. –mount=true –mount-string=’/home/josemanuelps/projects:/home/docker/projects’
Recommended deploy instrucctions:
kubectl create --save-config -f <(path_to_ansible_namespaces)>
kubectl apply -f <(path_to_ansible_directory)>
Example deploy instrucctions:
kubectl create --save-config -f ~/projects/kubernetes_rfd/ansible/basic/ns.ansible.yaml
kubectl apply -f ~/projects/kubernetes_rfd/ansible/basic
Last test info:
- Date: 25/07/2021
- Minikube version: v1.22.0
- Kubernetes version: v1.21.2
ansible/root:v1.0
This short tutorial explains in a simple way how to deploy an ansible laboratory based on https://github.com/JoseManuelPS/Docker_RFD ansible/root.
Note: To mount volumes in minikube please use the following args. –mount=true –mount-string=’/home/josemanuelps/projects:/home/docker/projects’
Recommended deploy instrucctions:
kubectl create --save-config -f <(path_to_ansible_namespaces)>
kubectl apply -f <(path_to_ansible_directory)>
Example deploy instrucctions:
kubectl create --save-config -f ~/projects/kubernetes_rfd/ansible/root/ns.ansible.yaml
kubectl apply -f ~/projects/kubernetes_rfd/ansible/root
Last test info:
- Date: 25/05/2021
- Minikube version: v1.19.0
- Kubernetes version: v1.20.2
botnet_generator:v1.0
This short tutorial explains in a simple way how to deploy a botnet using the script botnget_generator.py.
Note: To mount volumes in minikube please use the following args. –mount=true –mount-string=’/home/josemanuelps/projects:/home/docker/projects’
Recommended deploy instrucctions for master [Master controller]:
kubectl create --save-config -f <(path_to_ansible_namespaces)>
kubectl apply -f <(path_to_ansible_directory)>
Example deploy instrucctions for master [Master controller]:
kubectl create --save-config -f ~/projects/kubernetes_rfd/botnet_generator/master/ns.botnet.yaml
kubectl apply -f ~/projects/kubernetes_rfd/botnet_generator/master/
Recommended deploy instrucctions of namespace [Bots cluster]:
kubectl create --save-config -f <(path_to_namespaces)>
Example deploy instrucctions of namespace [Bots cluster]:
kubectl create --save-config -f ~/projects/kubernetes_rfd/botnet_generator/master/ns.botnet.yaml
Recommended instrucctions to create a new botnet [Bots cluster]:
python3 ~/projects/kubernetes_rfd/botnet_generator/botnet_generator.py [-h] [--name NAME] [--num NUM] path
Example instrucctions to create a new botnet [Bots cluster]:
python3 ~/projects/kubernetes_rfd/botnet_generator/botnet_generator.py --name test --num 10 new_botnet
Recommended instrucctions to apply new iptables rules [Bots cluster]:
sudo <(new_botnet_path)>/rules/iptables.sh
Example instrucctions to apply new iptables rules [Bots cluster]:
sudo ./new_botnet/rules/iptables.sh
Recommended instrucctions to deploy botnet [Bots cluster]:
kubectl apply -f <(new_botnet_path)>
Example instrucctions to deploy botnet [Bots cluster]:
kubectl apply -f new_botnet
Last test info:
- Date: 25/05/2021
- Minikube version: v1.19.0
- Kubernetes version: v1.20.2
nexus_repository_oss/minikube:v1.1
This short tutorial explains in a simple way how to deploy the Nexus Repository OSS image repository (https://www.sonatype.com/nexus/repository-oss) inside of minikube.
Start minikube with the parameter –insecure-registry, like this:
minikube start --insecure-registry 'docker.local:30500'
Add minikube ip to the /etc/hosts file with the following names:
- nexus.local (It will be used to access the nexus service)
- docker.local (It will be used to access the docker repository)
Use the following command to check it:
minikube ip
You must also enable the ingress addon. Use the following command to add it.
minikube addons enable ingress
Important: A deployment is going to be carried out without certificates, if you want to carry out a deployment with certificates you can find more information at: https://help.sonatype.com/repomanager3
Recommended deploy instrucctions:
kubectl create --save-config -f <(path_to_nexus_namespaces)>
kubectl create --save-config -f <(path_to_nexus_deployment)> -f <(path_to_nexus_service)> -f <(path_to_nexus_ingress)>
Example deploy instrucction:
kubectl create --save-config -f ~/projects/kubernetes_rfd/nexus_repository_oss/minikube/ns.nexus_repository.yaml
kubectl apply -f ~/projects/kubernetes_rfd/nexus_repository_oss/minikube/
Configure and access to your own Nexus Repository OSS.
Now your Nexus Repository OSS it’s ready. To use it, you must access to http://nexus.local:30501 address, log in as admin, and complete the initial setup.
Once you have successfully logged in, go to Settings>Security>Realms and enable Docker Bearer Token Realm.
After the configuration is complete, you must create a new Docker repository as type hosted with the http port 5000 and Allow anonymous docker pull enabled.
Once the deployment has been done, and the new Docker repository created you can connect to it following this steps:
- If you want to connect from outside of minikube create or modify the file /etc/docker/daemon.json to include the following content:
{
"insecure-registries": ["docker.local:30500"]
}
- Reset Docker daemon and start again minikube.
systemctl stop docker.service docker.socket systemctl start docker.service minikube start --insecure-registry 'docker.local:30500' - Connect from outside of minikube:
docker login docker.local:30500 - Connect from inside of minikube:
eval $(minikube docker-env) docker login docker.local:30500
Recommended push instrucctions:
docker tag <(image_name:version)> docker.local:30500/<(repository_name)>/<(image_name:version)>
docker push docker.local:30500/<(repository_name)>/<(image_name:version)>
Example push instrucction:
docker tag hello_world:v1.0 docker.local:30500/docker_repo/hello_world:v1.0
docker push docker.local:30500/docker_repo/hello_world:v1.0
Recommended pull instrucctions:
docker pull docker.local:30500/<(repository_name)>/<(image_name:version)>
Example pull instrucction:
docker pull docker.local:30500/docker_repo/hello_world:v1.0
Last test info:
- Date: 25/07/2021
- Base image versión: sonatype_nexus3:3.32.0
- Minikube version: v1.22.0
- Kubernetes version: v1.21.2