vSphere Cloud-Init not keeping the static IP - terraform

I'm getting odd behavior that I don't understand in dealing with vSphere and Terraform. My terraform code provisions a host in vSphere with a static network configuration (network, IP, mask, gateway, etc.), and on the first boot, it seems to be correct. The IP and relevant network settings are applied.
However on reboot, the network configuration falls back to DHCP, which fails.
I see in the /var/log/cloud-init.log file that on the first boot, it is able to successfully apply the config:
However after that, on reboot, it reverts to DHCP?
I noticed this issue when trying to bring up Consul on the host, and Consul complained that there wasn't an IPv4 address to bind to. So, when I rebooted, the IP was gone. So I don't think the address is applying correctly.
The terraform code works for DHCP based networks, but for some reason when I apply static configurations, it adds it once, and then doesn't seem like it keeps.
Anyone ever hit this similar issue?
Edit:
Troubleshooting further by reading the cloud-init debugs:
This is the first boot, which should be the base template.
The second boot, which should be the deployed host receiving the config from terraform -> cloud-init:

...it's a bug in vSphere.
https://kb.vmware.com/s/article/71264
Symptoms
Virtual Machine has cloud-init customization enabled and a static IP
After reboot the virtual machine is configured with DHCP
Cause
This issue occurs due to cloud-init considering the virtual machine as a new instance. This instance can not retrieve data from the datasource when there is no customization, and will have DatasourceNone applied defaulting to DHCP.
Resolution
Currently there is no resolution.
Workaround
To workaround this issue apply one of the following.workarounds:
Add the setting manual_cache_clean: True to the /etc/cloud/cloud.cfg for the customized virtual machine.
Uninstall cloud-init from the virtual machine

Related

Bridge to Kubernetes doesnt add entries in /etc/hosts

I need help with the Bridge to Kubernetes setup in my Linux(WSL) environment.
The debug starts as expected but it doesn't change my /etc/hosts, hence I can't connect to the other services in the cluster.
I believe the issue can be related to not having enough permissions, and I can't find endpointManager running in Linux.
https://learn.microsoft.com/en-us/visualstudio/bridge/overview-bridge-to-kubernetes#additional-configuration
Any idea what this could be related to?

Run gitlab on subdomain in local network?

I installed gitlab on a raspberry pi 4 in my local network and will use it only locally. When I configure in /etc/gitlab/gitlab.rb the external_url 'http://rpi4.local' (and execute sudo gitlab-ctl reconfigure afterwards) it works. I can even configure a different port here.
But the configuration external_url 'http://gitlab.rpi4.local' does not work. Do I need to configure something else, like my /etc/hosts file ?
You will need to make the name valid in DNS through some mechanism. There are multiple ways depending on your needs and your options for DNS.
As you mentioned, you can add the name to your /etc/hosts file. This should be done both on the GitLab server and on any workstation you wish to have access to GitLab (assuming Linux-based machines. The process differs for Mac or Windows).
Use a valid DNS name and add it to your DNS. Use a name such as gitlab.<a-domain-you-own> and add it to DNS. Many domain registrars offer DNS for free or you could use a dynamic DNS service if your Raspi has a dynamic internal address. The advantage of using this method is you won't have to modify any /etc/hosts files and all workstations will know how to access your GitLab instances without any changes.

Connecting Centos VMs to each other for K8s

Im trying to set up kubernetes on my centos VMs using virtualbox. I prefer to use the kubeadm method, so that I can join slave nodes with a join token.
My issue is that I think I am lacking understanding of how to connect my VMs to one another beforehand. This is the resource I am using for the Kubernetes installation:
https://www.profiq.com/kubernetes-cluster-setup-using-virtual-machines/
When I create VMs and run ifconfig, they all have the same IPs listed, even if they are new VMs and not just a copy of the original. I must be doing something wrong.
Anyway, Im just wondering if anyone would be so kind as to give me some steps to get my VMs talking to each other, just to be sure Im doing it correctly. Im following the article I posted, and can ping each VM from the other, but then ran ifconfig and, since each machine has the same 10.0.2.15 IP, I feel like its just pinging itself and not the master from slave, etc
Did you perform the step after the cloning and before you load kubernetes to change the IP addresses of the 2nd and 3rd VM?
from the instructions you are following, I see:
Now create a linked clone machines from kubemaster machines created before. Once you’re done, boot into machine and change following things to match infrastructure:
Set IP address 192.168.99.21 (or 22 for second slave) for host only network.
Set hostname hostnamectl set-hostname kubeslave1 (or kubeslave2 for second slave) Everything else is already configured.

Switching VMs and The Static IP

I recently changed the VM im running CentOS on to a new one, and everything works fine. Except that recently i face problems starting gogs, a self hosted git server, with the following error. As the erorr states, there is a problem with ip, apparently my old VM ip is still hardcoded somewhere in the VM, and this is the old ip im getting below.
Are there any linux configuration i should be aware of to update my new ip on the VM, knowing that ifconfig gets me the right ip, the new one.
Take a look at http://gogs.io/docs/advanced/configuration_cheat_sheet.html
You'll need to edit the file custom/conf/app.ini and change the value of HTTP_ADDR
Thanks to #Etan Reisner, I checked the /etc/hosts file on the system and made sure that host and dig from the new system return the correct IP address.

Azure virtual network - How to change localnetworksite address space?

I need to change the address space prefix in my virtual network configuration. How can I do this?
<LocalNetworkSites>
<LocalNetworkSite name="xxx-xxx-DC">
<AddressSpace>
<AddressPrefix>xx.xx.15.0/24</AddressPrefix>
<AddressPrefix>xx.xx.67.0/24</AddressPrefix>
</AddressSpace>
<VPNGatewayAddress>xx.xxx.xx.xx</VPNGatewayAddress>
</LocalNetworkSite>
</LocalNetworkSites>
Your extract shows the local network definition whilst your question seem to refer to the virtual network itself, but actually it doesn't really matter as the answer is the same - You can't change the address space for either on a created network.
You will have to
Export the configuration
Make the changes you require (make sure to change subnets as well)
Delete the network
Re-create the network by importing the modified configuration
Re-deploy your services
Yossi,
Is this a Microsoft supported solution?. The reason I ask is apart from having to create the vm's I also have to change the config on the local vpn side as the IP address of the gateway and shared key changes. Fortunately I only have 3 vm's but lets say I had 20, this would not be a sustainable solution at all.
I agree with user3120398 that this is not a viable and sustainable solution and it still seems to be modus operandi more than a year later :-(

Resources