In this blog post we are going to look at an ABX action that allows us deploy a Kubernetes YAML document, or multiple thereof , from a Cloud Template (previously known as Blueprint) in VMware Cloud Assembly.
- Introduction
- Exploring the ABX Action and Cloud Template
- Exploring the Cloud Template Deployment
- Final Step
Update Log:
Introduction
Cloud Assembly has native integration with Kubernetes and allows us to create Kubernetes Clusters , namespaces and Supervisor Namespaces. These all are available to be consumed as resources objects in the Cloud Template Editor.
Cloud Assembly does not offer us through a way to run a Kubernetes YAML documents , or multiple thereof , from a Cloud Template. We can do this from Code Stream Cloud , which has Kubernetes integration as well and offers a Kubernetes task that can run yaml document(s). Code Stream does not give us LiveCycle management on the deployment through.
To fill in the gab I’ve created a ABX action that will utilize the Namespace creation from Cloud Assembly , and therefore the LiveCycle of the deployment, it will allow us to run a Kubernetes yaml in that namespace to create a deployment.
Thinks of the ABX action as the equivalent of a kubectl create -f FILENAME command .
The action can be found on the following Gitlab Repo bit.ly/The-Gitlab. Action name is k8sCreateFromYaml
Special Thanks to Lazarin Lazarov and Teodor Raykov (https://www.linkedin.com/in/tedraykov/) for their work in the product and for providing me the skeleton and idea for this action
Let’s dig in into the action to see what it does.
Using the ABX Inputs
Let’s examine the ABX Action inputs and what they do:
- cspRefreshTokenIn (String): VMware Cloud Service Portal (CSP) Token
- actionOptionKubeconfigIn: (String): Select the kubeconfig to be used for the action
- admin: This uses an admin kubeconfig to authenticate to the Kubernetes cluster and run the YAML document.
- namespace: This uses an namespace kubeconfig to authenticate to the Kubernetes cluster and run the YAML document. This kubeconfig is limited to the scope of the namespace that was created as part of the blueprint deployment.
The ABX action need to be subscribed to the Kubernetes namespace post provision (kubernetes.namespace.provision.post ) Event Topic.
Among the self-explaining inputs the Cloud Template that we are going to use also has the following important inputs :
- yaml (String): This provides the yaml document , or documents to be run by the ABX Action. The Cloud Template also creates a namespace. If we want that namespace to be used in the yaml we need to place ABX-Parameter-K8sNamespace anywhere in the yaml documents where we want to reference the namespace name. The ABX action will substitute this with the appropriate namespace name.
- – actionOptionKubeconfig: (String): Select the kubeconfig to be used for the action.
- admin: This uses an admin kubeconfig to authenticate to the Kubernetes cluster and run the YAML document.
- namespace: This uses an namespace kubeconfig to authenticate to the Kubernetes cluster and run the YAML document. This kubeconfig is limited to the scope of the namespace that was created as part of the blueprint deployment.
- abx: This uses the kubeconfig specified in the actionOptionKubeconfigIn input property in the ABX Action. This allows the Cloud Template Editor to let the ABX Extensibility Editor to choose the kubeconfig file.
- #--------------------------------------------------------#
- # Spas Kaloferov #
- # www.kaloferov.com #
- # bit.ly/The-Twitter Social bit.ly/The-LinkedIn #
- # bit.ly/The-Gitlab Git bit.ly/The-Github #
- # bit.ly/The-BSD License bit.ly/The-GNU #
- #--------------------------------------------------------#
- info: |-
- #
- # VMware Cloud Assembly Blueprint Code Sample
- #
- # - Creates a K8s Namespace.
- # - Optionally also creates a deployment based on Yaml file.
- # - Do not change or rename any of the inputs.
- #
- name: K8S - Create From YAML
- version: 1
- #-------------------------INPUTS-------------------------#
- inputs:
- …
- actionOptionKubeconfig:
- comment: |
- This overrides the actionOptionKubeconfigIn action input
- configured in the ABX action. If you want to use the context
- configured in the action select abs as input.
- type: string
- title: Exec Context
- #format: hidden
- description: |
- Select KubeConfig to use for the run context. You can
- choose between the kubeconfig limited to the namespace
- being created or use an admin kubeconfig. Selecting 'abx'
- will use the context configured in the abx action
- default: namespace
- enum:
- - namespace
- - admin
- - abx
- yaml:
- comment: |
- This overrides the actionOptionKubeconfigIn actin input
- configured in the ABX action. <br>
- NOTE: use ABX-Parameter-K8sNamespace anywhere in the yaml
- where you want to use the name of the namespace which is
- provided by the inputs at request time.
- title: Yaml
- type: string
- format: hidden
- description: |
- Select KubeConfig to use for the run context. You can
- choose between the kubeconfig limited to the namespace
- being created or use an admin kubeconfig.
- default: |
- YAML Document 1
- ---
- YAML Document 2
- ---
- YAML Document 3
- …
Now in this example the yaml is hardcoded in the blueprint. But we can remove the format: hidden property, and by thus exposing it as user input. We can then build a custom form to frontend it so that the user can supply the yaml document at request time. Custom form is also included with the action.
Exploring the Cloud Template Deployment
One the Cloud Template has been provisioned and the ABX Action has completed. The deployment Name and Description will be auto-updates with a status of all the deployment pods and a link to the deployment load balancer , if such is deployed.
Final Step
If all went well, go grab a beer.
DISCLAIMER; This is a personal blog. Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated. Any views or opinions are not intended to malign any religion, ethnic group, club, organization, company, or individual.
All content provided on this blog is for informational purposes only. The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of this information.
Photos
Unless stated, all photos are the work of the blog owner and are licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. If used with watermark, no need to credit to the blog owner. For any edit to photos, including cropping, please contact me first.
Recipes
Unless stated, all recipes are the work of the blog owner and are licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. Please credit all recipes to the blog owner and link back to the original blog post.
Downloadable Files
Any downloadable file, including but not limited to pdfs, docs, jpegs, pngs, is provided at the user’s own risk. The owner will not be liable for any losses, injuries, or damages resulting from a corrupted or damaged file.
Comments
Comments are welcome. However, the blog owner reserves the right to edit or delete any comments submitted to this blog without notice due to
– Comments deemed to be spam or questionable spam
– Comments including profanity
– Comments containing language or concepts that could be deemed offensive
– Comments containing hate speech, credible threats, or direct attacks on an individual or group
The blog owner is not responsible for the content in comments.
This policy is subject to change at anytime.