Remove Docker persistent storage volumes from VMware datastore

After you have finished using your Docker persistent storage volumes you can remove them from the environment so you can clean them up and don’t consume more storage that what is really needed. Here is what you have to do do clean those up.

List your volumes

docker volume ls

You will see your docker volumes stored in your /vsanDatastore/dockvols folder

removedockvol1

Remove the volumes not needed

docker volume rm volumename

ex: docker volume rm MyVolume

removedockvol2

This will remove the volume from the docker host and will also remove it from the VMware vSphere datastore.

Deploying containers with persistent storage in VMware environments

In my last blog post I described how to install the VMware Plugin for Docker.  Now we will deploy an environment and show how we can use a persistent storage volume across containers.

Build a new volume for a container

docker volume create –driver-vmdk –name BusyBox1 -o size=2gb

vmdocksharevol1

You can check the volume with docker volume ls or docker volume inspect  commands.

Create a container with persistent storage

docker run –rm -it -v Volumename:/mnt/mymount containerimage.

docker run –rm -it -v BusyBox1:/mnt/myvol busybox

vmdocksharevol2

Create a file in the persistent storage

In your container go to the directory you specified in the previous command. In our case it is /mnt/myvol

Create a quick file ex: touch file1  and then add some information to it.

vmdocksharevol3

We have created a file in the persistent storage not in the container file system.

Now you can exit your container. ex: exit

Create a different container and attach the persistent volume

I will download a new image for an Ubuntu:latest container and mount the persistent storage volume.

docker run –rm -it -v BusyBox1:/mnt/myvol ubuntu

vmdocksharevol5

Change to the same directory /mnt/myvol and see that you can browse the file was created before.

Why is this important? 

This allows the developers or administrators to provide a persistent storage that can be used across container reboots to save data outside the container. This can be a great use case for database or shared data that can be used for different containers.

 

Drop me a comment if you like this type of post.

Leveraging the VMware Docker Plugin in your environment

You may have heard that VMware released a docker plugin. This plugin allows the developers use persistent storage and store it in the VMware datastore while allowing IT Administrators the capability to manage their environment their way.

In this post I will go thru the steps to add the all the components to the ESXi server and to the VM’s

Download Binaries

To download the binaries I used a Ubuntu machine.

1. create a folder to download the files. ex: mkdir vmware

2. change to the directory. cd vmware

3. download the files:

ubuntu package: https://github.com/vmware/docker-volume-vsphere/releases/download/1.0.beta/docker-volume-vsphere_1.0.beta_amd64.deb

ESXi vib package: https://github.com/vmware/docker-volume-vsphere/releases/download/1.0.beta/vmware-esx-vmdkops-1.0.beta.vib

Optional: I created a script that you can use to download all the files directly to your Linux Machine Download the Script from GitLab

Example: curl https://gitlab.com/carlosvargas/devops/raw/master/ubuntu/downvmdockplugin | sh

vmdockplugin1

Copy the VIB to your ESXi server

To copy the VIB file you can follow these steps

scp vmware-esx-vmdkops-1.0.beta.vib root@1.2.3.4:/vmfs/volume/datastorename/foldername/vmware-esx-vmdkops-1.0.beta.vib

vmdockplugin2

 

Enable Community Support for VIB

Connect to your ESXi host: ssh root@1.2.3.4

Enable community support for VIB files: esxcli software acceptance set –level communitysupported

Install the VMware Plugin VIB: esxcli software vip install –no-sig-check -v /vmfs/…./vmware-esx-vmdkops-1.0.beta.vip

vmdockplugin3

 

Copy VMware Docker Plugin to your Docker VM

scp docker-volume-vsphere_1.0.beta_amd64.deb user@1.2.3.4:/home/user/docker-volume-vsphere_1.0.beta_amd64.deb

vmdockplugin4a

 

Install the VMware Plugin in your Ubuntu VM

Login to your VM and install the plugin. Ex: sudo dpkg -i docker-volume-vsphere_1.0.beta_amd64.deb

vmdockplugin5

Reboot your node: sudo reboot

Create Docker Volume with the VMware Plugin

To create the volume you need to use the –driver=vmdk parameter. here is an example:  docker volume create –driver=vmdk –name=MyVolume -o size 10gb

vmdockplugin6
To check your volumes execute: docker volume ls

Where are this volumes stored? 

Go to to your vsanDatastore, you will see a new folder called docksvols. There you will find your new volume created.

vmdockplugin7

How to move a VM to another host without vCenter vMotion

Sometimes it is important to know the manual steps of  the automated task that vCenter executes. This will come handy in the event that vCenter server is down. Here is a list of steps that can help you move a VM from one host to another one without vCenter

  1. Power Off the VM
  2. Right Click the VM and select “Remove from Inventory”
  3. Go to the other host where you want to bring this VM up.
  4. Click Configuration à Storage à Click the datastore where the VM is located
  5. Right click the datastore à Browse datastore
  6. Look for the VM that you want to add on the left pane and click the folder
  7. Look on the right pane for a file with the name of the vm and the vmx extension. Example: server1.vmx
  8. Right click the .vmx file and select add to inventory.
  9. Now go to the server inventory and power on your VM.
  10. If you get a warning message, select I moved the vm.
  11. You should be back in business.

Hopes this helps

Automated Creation of VMware PortGroups

I was working on creating a new lab environment for Exchange 2013 and Lync 2013. I decide to create a couple of new portgroups with VLANs on all the ESXi servers. the task was going to be repeated 30 times so I decided to spend a little time creating a script to automate the process of creating all the port groups and the vlans.

[sourcecode]

############################################################
# ScriptName: Configure_PortGroups.ps1 #
# Function : Automate vSwitch0 PortGroup Creation #
# Author : Carlos Vargas #
############################################################

# Check is VMware Snapin is loaded
if ( (Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq $null )
{
Write-Host "Adding VMware PowerCLI SnapIn"
Add-PsSnapin VMware.VimAutomation.Core
}

# Define the Credentials
# Define the Username
$user = Read-host -Prompt "Type your username. Ex user1 or Domainuser1 or user@domain.com"
# Define the secure password
$pass = Read-host -Prompt "Type your password" -AsSecureString
# Convert Credentials to secure string
$mycreds = New-Object System.Management.Automation.PSCredential ($user,$pass)
# Pass $mycreds variable to any PowerShell Commandlet that support PScredentials value.

# Ask for the Host name or IP
$ESXHOST = Read-Host "Enter ESX Host Name or vCenter Server"
Connect-VIServer $ESXHOST -Credential $mycreds

# Get Hosts
$vmhosts = Get-Datacenter | Get-VMhost | Select-Object Name

# loop for the names
foreach ($i in $vmhosts)
{
$vs = Get-VirtualSwitch -VMhost $i.Name -Name vSwitch0
$portgroups = Import-CSV .portgroups.csv
Foreach ($portgroup in $portgroups){
#Write-Host "Portgroup Name: " $portgroup.name " vlanid : " $portgroup.vlanid
$vs | New-VirtualPortGroup -Name $portgroup.name -VLanID $portgroup.vlanid
}
}

[/sourcecode]

Hope this helps you. Drop me a comment and let me know what you think

Configure Windows Server 2012 or Hyper-V 2012 VM on ESXi 5

This configuration is not a supported in production. This is a tutorial for IT Pros to build a Lab environment with Windows 2012 or Hyper-V Server 2012

  1. Login to your VMware environment.
  2. Create a new VM

  3. Select to configure a custom VM

  4. Select the name for your Hyper-V server and the datacenter in the VMware environment.

  5. Select a cluster and resource pool.

  6. Select the datastore for the VM.

  7. Select Virtual Machine Version: 8

  8. Select Windows 2008 R2 (64-bit)

  9. Select the vCPU and Cores for the Hyper-V machine. Default is 1.

  10. Select the amount of RAM.

  11. Select to add 4 NIC cards and Select the E1000 as the Adapter.

  12. Select LSI Logic SAS

  13. Create a new virtual disk.

  14. Leave the defaults for the size. Select Thin Provision.

  15. Leave the default setting for the Virtual Device Node. Press Next

  16. Press Finish

  17. Click the Edit Settings link for the new VM created for Hyper-V.

  18. Click Options à CPUID Mask . Select Expose NX/XD Flag to guest and Advanced…

  19. Go down to Level 1 and in the ecx space type:

    —- —- —- —- —- —- –H- —-

  20. Click General à Configuration Parameters

  21. Add two rows with the following values
Name Value
monitor.virtual_exec hardware
hypervisor.cpuid.v0 FALSE

  1. Install Windows 2012 or Hyper-v Server 2012 in the new VM.

ESXi 5 Update procedure without Update Manager

If you have to update an ESXi 5 host and you do not have update manager or will like to automate the process. Here are 6 steps that you can follow to apply the updates.

Transfer update via vifs to datastore

vifs –server x.x.x.x –put filename.zip “[datastore1]filename.zip”

List the file copied

vifs –server x.x.x.x –dir [datastore1]

Put host in maintenance mode

vicfg-hostops –server x.x.x.x –operation enter

Apply updates

esxcli –server x.x.x.x software vib update -d /path/file.zip

Reboot host

vicfg-hostops –server x.x.x.x –operation reboot

Exit from Maintenance Mode

vicfg-hostops –server x.x.x.x –operation exit

How to stop a VM from the CLI in vSphere 5

As with every version there is a new set of tools to perform administration in your vSphere ESXi hypervisor. The new tool is called esxcli. Here are some steps to try to get shutdown a VM from the command line

Steps to stop a VM from the CLI in vSphere 5

  1. Gather information on the processes :  Ex: esxcli vm process list
  2. Select process World number from the list generated in step 1
  3. Send the kill command to stop VM. Ex: esxcli vm process kill -t soft -w #####

vCenter Appliance and Sysprep tools

VMware vCenter Appliance provides the capability to manage your environment from a simple VM without the need to have another Windows server to manage the VMware vSphere Infrastructure. As this appliance is based on SUSE Linux; Where will you copy the Sysprep tools for your VM’s?  The location is /etc/vmware/sysprep  there you can copy the files for your sysprep customization.

VMware KB2004013

VMware support documentation and 3rd party tools list

For all my friends and co-workers that constantly ask can you send me the links for that documentation. I will start compiling a list of all the support documents and tools I currently use for VMware virtualization technologies.

Documentation

  1. VMware ESXi 5 documentation
  2. VMware vSphere 4.1 documentation

Videos

  1. VMware TechPubs video library
  2. VMware Hot Add features
  3. VMware DPM Demo
  4. VMware Fault Tolerance Demo
  5. VMware Distributed switch Demo
  6. VMware vSphere 5 Port Mirroring
  7. Cisco Nexus 1000v Demo
  8. VMware VMDirectPath Demo

Tools

  1. RVtools (Inventory your vSphere Infrastructure)
  2. PowerGUI (PowerShell Reporting and Editor for VMware and Microsoft)
  3. vDiagram (Diagram your VI environment with PowerShell and MS Visio)
  4. vCheck (Report of your VI Environment)
  5. PortLock (Virtualization Support for Novell Server Storage for P2V)
  6. CloneZilla (OpneSource Imaging and Cloning Solution)
  7. BleachBit Portable (Temporary File Cleaner Utility)
  8. Inventory Scripts  (Scripts to interact with the vSphere Inventory)
  9. Find Snapshots
  10. Remove Snapshots