Skip to main content

A python based proof of concept of an operator to manage VMware Cloud Director ressources

Project description

Kubernetes vCD operator

A python based proof of concept of an operator to manage VMware Cloud Director ressources.

Features

kvcd is a proof-of-concept of a python based kubernetes operator to manage VMware vCloud Director resources.

With this first preview release, you can manage the state of vApp objects with the following configuration properties:

  • Parent Org (creation only)
  • Parent Org VDC (creation only)
  • Name (creation only)
  • Description
  • Fence mode (creation only)
  • EULAs acceptance (creation only)
  • Ownership
  • Power status: on/off
  • deploymentLease
  • storageLease
  • source catalog: if cloned from vCD library item
  • source template: if cloned from vCD library item
  • metadata: through the Kubernetes resources annotations: ReadOnly on vCloud Director side.

The operator also populates a status.backing dictionnary with the following properties according to the vCloud Director data:

  • UUID
  • status
  • vcd_vapp_href
  • vcd_vdc_href
  • owner
  • deploymentLeaseInSeconds
  • storageLeaseInSeconds
  • metadata

If a deviation is detected with the declared specs of the object: a reconcialiation is made to apply the state from the declared specs.

It may remains some use-case where the reconcialiation will fail like when trying to apply a power-on expected state on an expired object.*

The same reconcialiation process will occurs when a change is made to the specs object declaration to apply changes to the backing object on vCloud Director.

Modification of some specs properties will be ignored, such as org, vdc, fence_mode or accept_all_eulas.

Installation

Stable release

To install Kubernetes vCD operator, run this command in your terminal:

pip install kvcd

This is the preferred method to install Kubernetes vCD operator, as it will always install the most recent stable release.

If you don't have pip installed, this Python installation guide can guide you through the process.

From sources

The sources for Kubernetes vCD operator can be downloaded from the Github repo.

You can clone the public repository:

git clone git://github.com/lrivallain/kvcd

Once you have a copy of the source, you can install it with:

pip install .

Usage

Configuration

Create a .venv file with the following content, according to your setup:

# Hostname of the vCloud instance
KVCD_VCD_HOST=vcloud.domain # mandatory

# HTTPS port to the vCloud instance
KVCD_VCD_PORT=443 # optional: 443 by default

# Organisation of the vCloud user
KVCD_VCD_ORG=orgX # mandatory

# vCloud credentials to use as a service account
KVCD_VCD_USERNAME=kvcd-svc # mandatory
KVCD_VCD_PASSWORD=********** # mandatory

# Verify the SSL certificate to connect to vCD instance
KVCD_VCD_VERIFY_SSL=yes # optional: yes by default

# Delay between two refresh of the vCD session
KVCD_VCD_REFRESH_SESSION_INTERVAL=3600 # optional: 3600 by default

# Refresh interval of the vCloud instance data for each object
KVCD_REFRESH_INTERVAL=10 # optional: 10 by default

# Warming up duration
KVCD_REFRESH_INITIAL_DELAY=30 # optional: 30 by default

# Reduce the number of timer checks when the ressource is changed
KVCD_REFRESH_IDLE_DELAY=10 # optional: 10 by default

Test namespace

For the test, we will deploy a test namespace on the Kubernetes cluster:

kubectl create namespace "test-kvcd"

Deploy the CRD

Deploy the Custom Resource Definition by using the following commands:

export KVCD_VERSION="v0.1.0"
kubectl apply -f https://github.com/lrivallain/kvcd/releases/download/${KVCD_VERSION}/kvcd-crds.yaml

This will deploy the definitions of objects that are managed by the current operator.

Run locally

The current PoC can be run locally or be embeded in a Kubernetes deployment (with pods, service...).

The local deployment is easier to debug and troubleshoot but requires that the script remain running to manage resources.

The embeded deployment is probably a better choice for a real-use-case but may be more complexe to troubleshoot.

For the early versions, the documentation will only cover a local execution of the operator backend.

# Run operator with kopf command and listen to specific namespaces
kopf run -m kvcd.main --namespace="test-kvcd" --verbose

Test

You can now deploy a test empty vApp to check the behavior of the operator:

cat << EOF | kubectl apply -f -
---
apiVersion: kvcd.lrivallain.dev/v1
kind: VcdVapp
metadata:
  name: kvcd-test-vapp1
  namespace: test-kvcd
  annotations:
    app: app01
    isprod: "false"
    version: "0.1.0"
spec:
  description: Test description
  org: <name of your org>
  vdc: <name of your org VDC>
  owner: <name of the owner to set>
EOF

kubectl get vcdvapp

After a couple of seconds, you should get something like this:

NAME              ORG        VDC             STATUS       UUID
kvcd-test-vapp1   <org>      <org vdc>       Resolved     urn:vcloud:vapp:a2871e71-49ab-48a4-a6dc-4c11743b7ba7

You can now edit fields values, delete or manage the vApp like a kube object.

Cleanup

kubectl delete -n test-kvcd vcdvapp kvcd-test-vapp1
kubectl delete namespace test-kvcd

History

0.1.0 (2021-08-13)

  • First release on PyPI.

kvcd is a proof-of-concept of a python based kubernetes operator to manage VMware vCloud Director resources.

With this first preview release, you can manage the state of vApp objects with the following configuration items:

  • Org (creation only)
  • Org VDC (creation only)
  • Name (creation only)
  • Description
  • Fence mode (creation only)
  • EULAs acceptance (creation only)
  • Ownership
  • Power status: on/off
  • deploymentLease
  • storageLease
  • source catalog: if cloned from vCD library item
  • source template: if cloned from vCD library item
  • metadata: through the Kubernetes resources annotations: ReadOnly on vCloud Director side.

The operator also populates a status.backing dictionnary with the following properties according to the vCloud Director data:

  • UUID
  • status
  • vcd_vapp_href
  • vcd_vdc_href
  • owner
  • deploymentLeaseInSeconds
  • storageLeaseInSeconds
  • metadata

If a deviation is detected with the declared specs of the object: a reconcialiation is made to apply the state from the declared specs.

It may remains some use-case where the reconcialiation will fail like when trying to apply a power-on expected state on an expired object.*

The same reconcialiation process will occurs when a change is made to the specs object declaration to apply changes to the backing object on vCloud Director.

Modification of some specs properties will be ignored, such as org, vdc, fence_mode or accept_all_eulas.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kvcd-0.1.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

kvcd-0.1.0-py2.py3-none-any.whl (13.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file kvcd-0.1.0.tar.gz.

File metadata

  • Download URL: kvcd-0.1.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.11

File hashes

Hashes for kvcd-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3f6d92e656aaee008a24914313f38961b2990cdcc9b58c035f15f7a434df6e7d
MD5 3223549d0a005840a33a2bfb9837c03e
BLAKE2b-256 0d1bff7e6af9752524618936d5463939619fcc494907f3a28e132256a09e5eb5

See more details on using hashes here.

File details

Details for the file kvcd-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: kvcd-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.11

File hashes

Hashes for kvcd-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ccd5ac54aa1a79bc990db7493f5b870391a5bc3506981eaa5b05ab039ae02b1f
MD5 c62f8a03489b1c590fb83ee239384121
BLAKE2b-256 c7a68bb3f293e764c66181e8daf5059d1777060d4e72c6190b83e783e9b34585

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page