Category Archives: vSphere with K8s

Posts on vSphere with K8s

Automating key vSphere Supervisor cluster operations using Java SDK

Recently I got an opportunity to work as technical reviewer of the programming guide wrt vSphere with KubernetesĀ Configuration and Management (pdf here). As part of that, I had contributed few key Java API samples around vSphere Supervisor cluster into open source vSphere Automation Java SDK. I thought it is good to brief you about the same and also share key getting started tips around vSphere Automation Java SDK. If you are new to vSphere with Tanzu (aka vSphere with K8s) capability, I suggest you to go through below articles.

1. Introduction to vSphere Supervisor Cluster REST APIs
2. Python scripts to configure Supervisor cluster & create namespaces

Basically there are 3 Java API samples. If you are just looking for samples, just refer below links.

  1. Enable Supervisor cluster,
  2. Create Supervisor namespace and
  3. upgrading Supervisor cluster to next available kubernetes version.

Getting started tips : Enabling Supervisor Cluster with vSphere Automation java SDK

  1. It is assumed that you already have a base environment with NSX-T stack as specified here . Note that there is vSphere with Tanzu through vSphere network stack introduced with vSphere 70U1 as well. It is just that the sample I had contributed around enabling workload management feature (i.e. Configuring your vSphere cluster as Supervisor cluster) is applicable to NSX-T stack. I will contribute vSphere network stack based sample as well.
  2. Before you start, please understand this general REST API doc around Supervisor cluster enable operation. I love using this brand new developer portal. As a beginner, I would just spend around few minutes. It is fine if you did not understand few things, just move on.
  3. Now it is time to build your vSphere automation Java SDK environment in Eclipse. Steps for building it are explained here
  4. Once your eclipse environment is ready and added all samples into your eclipse project, you would also get all Supervisor cluster related samples I contributed into your eclipse project under “namespace_management” package. You can optionally spend few minutes, its fine if you could not, lets move on.
  5. In order to automate anything using vSphere automation Java SDK , it is important that you understand Java specific vSphere Automation doc. Note that this doc is different from the one mentioned in step 2 above. Again just spend few minutes understanding how it is organized and move on. As you spend more time, you will be comfortable referring it.
  6. Once you got fair idea around java specific doc as mentioned in step 4, now you can start looking at Java specific API doc for enabling workload platform i.e. Enabling vSphere cluster as Supervisor cluster. This is the doc I used to write this sample, just spend 1-2 min on this and move on.
  7. While you are going through doc in step 6, start co-relating it in parallel with actual java code sample around the same. Co-relating with doc and code will make your understanding better.
  8. Please closely look at what params are passed and EnableSpec is built.

Creating Supervisor namespace

  1. Most of the steps mentioned above applies here also. You can simply move to next step and take a look at this sample directly.
  2. This is the sample you need to understand for creating Supervisor namespace. Good thing is that same sample applies to creating namespace with either NSX-T or vSphere networking stack. With vSphere networking stack, there is one new param introduced i.e. networks on which you want to create this Supervisor namespace. Here is the Java Specific documentation around this API

Upgrading Supervisor cluster to next available kubernetes version.

  1. Upgrading Supervisor cluster deserves one separate post, which I will do as I get time but meanwhile you can learn more about it here
  2. Java sample for the same is here.

This is all I have in this post. I hope it was useful post. If Java SDK is not your thing, you can simply automate Supervisor cluster ops using either python as I did or use official vSphere Automation python SDK or go for DCLI also. In addition, it is important to note that VMware has decided to deprecate vSphere Automation .NET and Perl SDK (VMware KB) to more focus on Java, python and Go SDKs.