Skip to main content

Running Salt Master In Docker Container From Scratch 


In this post, we will install salt master in docker container and configure the public IP so it will be reachable from outside.

Prerequisites:  
  • Ubuntu host up and running.
  • Public IP should be configured.
  • Docker should be installed.
Skip to end of metadata

Pull Ubuntu docker image

docker pull  ubuntu:14.04.5
It will download the Ubuntu docker image.


Create a container for salt master
docker run -ti --name salt-master-server  --net=none --privileged=true ubuntu:14.04.5 bash
This will create a container, we will use the same container to install salt master. Now configure the network for this container.

Assigning an IP for a container

Here I am assuming that host machine is having interface "eth0" with public IP configured. Name of the container is salt-master-server. The below steps needs to be performed on the docker host.
  • Create a virtual interface

    $ ip link add name veth0 link eth0 type macvlan mode bridge
     New virtual interface "veth0" will be created.

  • Get the process id for the salt master container

    $ docker inspect -f '{{.State.Pid}}' salt-master-server
  • $ mkdir -p /var/run/netns

    $ ln -s /proc/<processid>/ns/net /var/run/netns/<processid>

  • Assign the virtual interface to salt-master

    $ ip link set veth0 netns <processid> name eth0
  • Get the public Ip to virtual interface

    $ docker exec -it salt-master-server dhclient -v eth0

Note: If you are facing any issue on assigning the static public IP to the container then check out     this guide

Install salt master on newly created container
  • Login into the container

    $ docker attach salt-master-server
  • $ apt-get update
    $ apt-get install software-properties-common
    $ apt-get install python-software-properties
  • Install salt master

    $ add-apt-repository ppa:saltstack/salt
    $ apt-get update
    $ apt-get install salt-master salt-ssh salt-cloud salt-doc
    $ service salt-master start

Here we have added the salt stack ppa and installed the salt master. We have also installed the salt-ssh and salt-cloud, which give us more flexibility to connect and control the resources. You can also change the default settings in /etc/salt/master if needed.

Check out this video:




You should have a salt master configured to manage your infrastructure. To configure salt minion in the docker container check out this guide. 
          

Comments

Popular posts from this blog

Monitor Any Java Process With Jolokia Hello, friends, I am writing this post because I struggled a lot to find out the solution for this. I was having a running java application on my machine and I wanted to monitor the performance  of that application. There are various tools to monitor the java process like: JConsole Jolokia You will find many posts about monitoring java process through JConsol, So let's not discuss that topic here anymore. In this post, we are going to discuss the Jolokia. To Monitor any java process via Jolokia fellow below steps: Download Jolokia JVM agent from here: https://jolokia.org/download.htm l e.g.  jolokia-jvm-1.5.0-agent.jar Assuming that you are having a running java process in your machine with PID  1234 Start the Jolokia JVM agent by running below command to monitor a java process java -jar jolokia-jvm-1.5.0-agent.jar start 1234              ...

HTTPS for Local Development

  Switching between HTTP to HTTPS for Local Development There are millions of developers who write web applications every day. While writing these  applications generally they run them locally or in the test environment to test the functionally, before releasing them to production. These applications expose HTTP endpoint using which they can be accessed and tested. Some times it requires to test the same application using HTTPS. I came across with this use case while working on CloudWatch Metric Streams, where I wanted to send the CloudWatch Metric Streams data to the monitoring solution using Kinesis Data Firehose, and it only accepts HTTPS endpoint. To accomplish the task I wrote one spring boot application . I was running this locally and it was exposing the HTTP endpoint, and the same endpoint can not be used in the Kinesis Data Firehose. It should expose HTTPS Endpoint.  There are many ways to expose the HTTPS endpoint and using ngrok it can be easily done. Install n...