Wednesday, April 19, 2017

Using Saltstack to set up Containers on any salt minion 
Introduction: Saltstack is a communication and relay mechanism between a salt master and several hundreds of minions. The communication happens over a super fast messaging and guaranteed delivery message bus called ZeroMQ. Commands issued at the master go over encrypted channel to the salt minion and are executed locally. Individual commands and batches can be executed seamlessly between minions of different flavors in a platform agnostic manner. 
Dedicated high density Linux flavor minions can host Linux Containers that behave like individual VMs. These containers can be configured to be on the same network and released to customers for access via SSH. Configuration and setup of these containers involve the use of shell commands within the container and LXC commands on the container host. These are easily invoked from the saltmaster and so the create, update and delete of containers can easily take place on command line via salt and ssh  
Salt also has flexibility in organizing scripts and states based on flavor, version and release. This let us determine the set of customization scripts to run on the container.  If there are states that affect all containers globally, then we can apply them via pillars. Otherwise we can even target minion Linux hosts by pools of predetermined list. This is especially helpful to release containers of different os flavors and they are best suited for configuring static ip addresses on all new containers. 
In addition, Salt has access to databases where it can look up and save any information it wants for the containers spun up using its framework.  This way the infrastructure knows which containers belong to which users. This is helpful because we want to authorize create, update and delete of containers to their respective owners. Actions such as taking snapshots and restoring snapshots as well as making clones from both containers and snapshots should be user driven where they leverage a portal that works with Salt framework.  Typically such a portal automates actions that the administrator would take via salt commands from the salt master. This makes the framework reusable by both administrators and users and streamlines the actions to the well known salt syntax.  
Finally, each container can also automatically become a salt minion registered with the same master, therefore it can also be managed independently as a minion. This is a significant win for management because all new instances become automatically available for regular maintenance and system administration activities. The same concept is available in public clouds where a system management center can interact with instances in any public cloud and on-premise system using  an agent on that instance. By installing salt-minion service on the new containers, they become first class citizens in the salt framework and are available to be managed just  like the rest of the inventory. Both the host and the container can now be prepared from Saltstack.
Conclusion: Containers are no different than virtual machines for users. If the virtual machines are managed by a central framework, we can reuse the same framework by promoting containers at par with the virtual machines. 
#codingexercise
Find ways an integer can be expressed as a sum of nth power of unique natural numbers
There are two numbers given x and . We have to find the number of ways x can be expressed as nth power of unique natural numbers.
        static int GetPower(int x, int n, int i, int sum)
        {
            int count = 0;
            int power = (int)Math.Pow(i, n);
            while (sum + power < x)
            {
                count += GetPower(x, n, i + 1, sum + power);
                i++;
                power = (int)Math.Pow(i, n);
            }
            if (power + sum == x)
            {
                // Console.WriteLine("power={0}, sum={1}", power, sum);
                count++;
            }
            return count;
        }
power=9, sum=1
Count = 1

No comments:

Post a Comment