Maybe you heard about the newly released Tanzu Platform!
VMware Tanzu Platform provides everything that you need to build application development environments, develop applications, and push those applications to production quickly, consistently, scalably, and securely.
Tanzu Platform includes a complete set of solutions depicted in the following diagram:
More details about these components are provided here.
Tanzu Platform Runtime for Kubernetes
Tanzu Platform includes runtimes for both Cloud Foundry and Kubernetes. Choose your runtime and get streamlined workflows to deploy your app with a few simple commands to Cloud Foundry or Kubernetes.
In this blog post, we will focus specifically on the build and deploy process on Kubernetes for a simple “Hello World” app, the “world-famous” Tanzu Java Web App, using Tanzu Platform. The source code of the application is available in this repository on my GitHub site.
Let’s get started by cloning the demo app:
git clone https://github.com/viktoriousss/nl-tanzu-java-web-app
Now, log in to Tanzu Platform:
tanzu login
Select your project and space:
tanzu project use tanzu space use
If it’s the first time you’re deploying the app, you might want to run:
tanzu app init
Navigate to the directory of the app and deploy it:
tanzu deploy
The tanzu deploy
command will trigger a build of the app, upload it to my registry, manage the DNS registration, and, of course, deploy the app to a Kubernetes cluster managed by Tanzu Platform. Now, our app is deployed to Kubernetes and is available at http://nl-tanzu-java-web-app.viktoriouslab.nl. Without a single kubectl command :), without any Docker files and just a little bit of YAML.
So what happened behind the scenes? We’ve built a new version of our app, uploaded it to a registry, and deployed it to a Kubernetes cluster. We’ve also created a DNS registration and configured inbound connectivity so the Tanzu Java Web App is able to receive traffic and display the “Greetings from Tanzu Platform” message. It’s also pretty easy to publish an update to the app, after saving the update use:
tanzu deploy --patch --yes
to deploy the update. Of course these commands can also be executed as part of a CI/CD flow, depending on your scenario.
Everything you see here is about abstraction! Kubernetes abstracts infrastructure concepts like storage volumes, networking, load balancers, and scaling into objects like deployments, replica sets, pods, services, persistent volumes, and more. Tanzu Platform abstracts these Kubernetes concepts into four “golden commands”: build, deploy, bind, and scale. In the example, only the first two commands are used.
You can see what’s running in the Kubernetes space by executing
kubectl get all -n viktorious-space01-<some-unique-id>
Two http routes are also being created
kubectl get httproutes.gateway.networking.k8s.io3
The required YAML code to deploy this app are available in these files and directories:
- The tanzu.yml file in the root of the app directory refers to the configuration directory of this app, being ‘.tanzu/config/’.
- The ./tanzu/config/ folder contains (in this case) two files, nl-tanzu-java-web-app.yaml describes the basic properties of this application. The file k8sGatewayRoutes.yaml defines the network configuration for the application.
- Any other configuration YAML files can be added to this directory if required. These YAML files are generated only once, if nothing changes they stay as they are.
More details about the setup of your workstation
…or a runner that is part of a CI/CD flow and is executing these commands.
Before the App is deployed, you have to setup a few things.
A container runtime is required on your workstation
You will need a container runtime to be available on your workstation, because the build process is executed locally. This container runtime can either be Docker or Podman.
You will need a (private) registry to save your container images to
You will need a registry to you can use for your container images, the local docker client needs to be able to access this registry using
docker login <url-of-your-registry>
The Tanzu command needs to know about this registry, using the following command:
tanzu build config --containerapp-registry <url-of-your-registry>/tanzu-platform/{name}
In this command the ‘{name}’ part is required, and will be adjusted to the actual name of the app you are deploying. The “tanzu-platform” part is the name of the repository on your registry.
Using
tanzu build config view
you can check the current configuration. The configuration is saved in ~/.config/tanzu/build/config.yaml – you can also edit this file.
The configuration of Tanzu Platform for Kubernetes
Behind the scenes the Tanzu Platform for Kubernetes is configured to make all these things just work!
For this scenario I’ve deployed an Amazon EKS cluster, defined an Availability Target, required Capabilities are installed automatically, defined a Space and added Profiles & Traits so that my developers are able to deploy Kubernetes apps without actually knowing Kubernetes.
In the Tanzu Platform documentation there are two chapters that explain this initial setup:
- Set up the infrastructure to create an application environment: This chapter explains the initial setup and configuration of the Kubernetes underlay and Route53 DNS integration. At the end an EKS cluster is deployed.
- Create an application environment using Spaces: This chapter provides the required steps to setup a Space, including required Profiles and Traits. You need to customize the multicloud-ingress.tanzu.vmware.com Trait to be able to interact with Route53.
You can also follow the documentation if you want to deploy the pre-build “Where-for-dinner” app. This app is hosted on a public registry. My Tanzu Java Web App is using a private registry, which requires an additional setup step.
Setting up a Private Registry on Tanzu Platform
If you want to deploy your own app, you need to configure a private registry. In the previous paragraph, the setup for your workstation/runner was explained. The Kubernetes cluster also needs to be able to access the private registry. For this, you need to configure the Registry Pull Only Credentials Installer capability. This capability allows you to configure the registry URL and logon credentials for the private registry you want to use. The capability is installed to a Cluster Group, and all the clusters added to the Cluster Group will have the capability installed on the actual Kubernetes cluster. By adding this capability to the Profile that is linked to the Space (and its Availability Targets), you ensure that this Space requires a Kubernetes cluster with this specific capability installed.
In this example, you can see that the “Registry Pull Only Credentials Installer” is deployed to the “run” cluster group. This capability has my registry URL + credentials configured. The EKS cluster I am using is part of the “run” Cluster Group.
Setting up the Profile for the private registry
Actually, the Profile is very basic and only includes the Registry Pull Only Credentials capability.
Setting up the Space
Now setup the Space that include the following profiles:
The spring-dev.tanzu.vmware.com is a profile that takes care of the different capabilities for Spring based apps. The viktorious-net-profile (a.o.) includes the connectivity to Route53 and the viktorious-registry-profile makes sure we have the credentials of the private registry available!
This is it. I hope this gives you an idea of the power of Tanzu Platform.
Stay tuned for more updates and tips on leveraging the full potential of the Tanzu Platform to streamline your application development and deployment processes.