Last active
September 18, 2022 04:05
-
-
Save redtripleAAA/9730666d783f0702bfb1754798f0e826 to your computer and use it in GitHub Desktop.
Dockerfile Template for Workloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################# | |
# The following .dockerfile can be used as a docker image for the following repo # https://github.com/brian1917/workloader | |
# Published Docker image can be used from Dockerhub # ansred/ubuntu-workloader-ssh # https://hub.docker.com/repository/docker/ansred/ubuntu-workloader-ssh | |
# This docker file will use Ubuntu AMD64 image and install all utility packages, inlcuding OpenSSH Server to access to the server # user= testuser # password=testpassword and port exposed 22 | |
# You can build this dockerfile (Make sure to change credentials used for OpenSSH | |
# Make sure to edit pce.yaml as well with your Workloader information of simply used pce-add command | |
# Tip # You can use to test the dockerhub test image # https://labs.play-with-docker.com/ | |
# Just run # "docker run -d -p 2022:22 --name workloader-ssh ansred/ubuntu-workloader-ssh" | |
# Note this flag if you wish delete the container when it stops --rm "docker run --rm -d -p 2022:22 --name workloader-ssh ansred/ubuntu-workloader-ssh" | |
# Example ssh -p 2022 [email protected] | |
# This dockerfile will automatically downloaded the latest linux repo for workloader from github and extract it for you to use at # /var/workloader/linux/linux-v8.24.6 | |
#!/bin/bash | |
################################################################################################## | |
#image ansred/ubuntu-workloader-ssh | |
#!/bin/bash | |
FROM amd64/ubuntu | |
RUN apt-get update && apt-get upgrade -y | |
RUN apt-get install -y byobu curl git htop man zip unzip vim wget nano sudo openssh-server sshpass iputils-ping telnet traceroute | |
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 testuser | |
RUN echo 'testuser:testpassword' | chpasswd | |
RUN service ssh start | |
EXPOSE 22 | |
ENV TERM linux | |
ENV DEBIAN_FRONTEND noninteractive | |
################################################# | |
#Create directory for Workloader linux | |
RUN cd /var | |
RUN mkdir /var/workloader | |
RUN mkdir /var/workloader/linux | |
RUN cd /var/workloader/linux && curl https://api.github.com/repos/brian1917/workloader/releases/latest | grep "browser_download_url.*linux.*.zip" | cut -d ':' -f 2,3 | tr -d \" | wget -O workloader-linux.zip -qi - | |
RUN cd /var/workloader/linux && unzip workloader-linux.zip | |
#RUN export PATH=$PATH$( find /var/workloader/ -type d -printf ":%p" ) | |
RUN cd /var/workloader/linux/linux* | |
RUN cd /var/workloader/linux/linux* && ./workloader version | |
RUN chmod -R 777 /var/workloader/linux | |
CMD ["/usr/sbin/sshd","-D"] | |
################################################################################################## |
Example line-by-line from after deploying the container
docker run -d -p 2022:22 --name workloader-ssh ansred/ubuntu-workloader-ssh
and then ssh to it
ssh -p 2022 [email protected]
[node2] (local) [email protected] /
$ ssh -p 2022 [email protected]
The authenticity of host '[192.168.0.17]:2022 ([192.168.0.17]:2022)' can't be established.
ED25519 key fingerprint is SHA256:xwKyyoIhts9yj7uYSW52wwgjTrsvIFUlgrFjSvLsCJ8.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[192.168.0.17]:2022' (ED25519) to the list of known hosts.
[email protected]'s password:
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 4.4.0-210-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.
To restore this content, you can run the 'unminimize' command.
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
testuser@cbb6351f6db8:~$ sudo su -
[sudo] password for testuser:
root@cbb6351f6db8:~#
root@cbb6351f6db8:~# ls
root@cbb6351f6db8:~# cd /var/workloader/linux/linux-v8.24.6/
root@cbb6351f6db8:/var/workloader/linux/linux-v8.24.6# ls
illumio-templates workload-identifier-default.csv workloader
root@cbb6351f6db8:/var/workloader/linux/linux-v8.24.6# printf "
debug: false
default_pce_name: pce-illumio-com
max_entries_for_stdout: 100
no_prompt: false
output_format: both
pce-illumio-com:
disabletlschecking: false
fqdn: pce.illumio.com
key: 4e7ce63a4329890a9afacb9accd8821
org: 1
port: 443
user: api_126220928cc25f
userhref: /users/1
target_pce: pce-illumio-com
update_pce: false
verbose: false
" >> pce.yaml
root@cbb6351f6db8:/var/workloader/linux/linux-v8.24.6# ls
illumio-templates pce.yaml workload-identifier-default.csv workloader
root@cbb6351f6db8:/var/workloader/linux/linux-v8.24.6# ./workloader -h
Workloader is a tool that helps manage resources in an Illumio PCE.
Usage:
workloader [command]
Docker Compose
#################################################
version: '3.3'
services:
ubuntu-workloader-ssh:
ports:
- '2022:22' # To be used for SSH to the container and ssh -p 2022 [email protected] and password is "testpassword"
container_name: workloader-ssh
image: ansred/ubuntu-workloader-ssh
#################################################
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can populate the pce.yaml by running workloader pce-add or copy the following template (Make sure to create your own PCE service account API key and PCE info)
Note: Make sure you are root in that directory
To populate multi-line text file from shell, use printf
Quick test for workloader (if you have some workloads in idle to run the following to print in console the output via stdout)
./workloader compatibility -i --out stdout
Expected output should look like this (depends on your workloads for sure)