Sunday, December 11, 2016

Today we take a break to talk about LXD containers and how to enable static ip addressing of the containers instead of the conventional DHCP.
Many organizations find it easier to hand out specific ip addresses and ip address ranges rather than have Linux containers obtain ip addresses in a range over DHCP. This lets them tightly control which ip addresses containers may be assigned to and facilitates static ip networking for separation of network from the more heavily used networks.
Static ip networking method for linux containers is described here : http://jason.trickett.us/2016/08/lxd-containers-static-ip-addresses-heres/ That post says that we can specify static ip address with

sudo sh -c "echo 'dhcp-host=containername,ipaddress' >> /etc/default/lxd_dnsmasq.conf"

once we have mentioned LXD_CONFILE="/etc/default/lxd_dnsmasq.conf" in /etc/default/lxd-bridge
Here we briefly mention the containers capabilities and design that facilitate this
First, the container provides the ability to create bridged networks by default. This lets outside in connectivity to the containers over a single interface of the host server
Second, LXD facilitates customizations with the following parameters specified in /var/lib/lxc/ContainerName/config

lxc.network.name this is the name given to the interface and is used to override the dynamically generated name
lxc.network.hwaddr this is the interface MAC address to override the one provided
lxc.network.ipv4 this is the ipv4 address to assign to the virtualized interface and also includes the broadcast address
lxc.network.ipv4.gateway this is the ipv4 address to use as the gateway inside the container.

With these four parameters, we can pretty much define the connectivity for the containers fully.


#codingexercise
Find the minimum number of merge operations to make an array palindrome.
For example,
arr[] = {15, 4, 15 } Answer : 0  // already a palindrome
arr[] = {1, 4, 5, 1}  Answer :  1 //  merge 4 and 5 to 9
arr[] = {11, 14, 15, 99} Answer : 3 // merge all

int GetMinMerge(List<int> arr)
{
int count = 0;
int start = 0;
int end = arr.Count-1;
while (start <= end)
{
if (arr[i] == arr[j])
{
start++;
end--;
}
else if (arr[i] > arr[j])
{
j--;
arr[j]+=arr[j+1];
count++;
}
else
{
i++;
arr[i] += arr[i-1];
count++;
}
}
return count;
}
#writeup https://1drv.ms/w/s!Ashlm-Nw-wnWlkDRgzKeR5lVB1Ml

No comments:

Post a Comment