vsphere

module
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2023 License: Apache-2.0

README

Go Reference Go Tests Latest Release Go Report Card codecov go.mod Go version

tl;dr

Convenience libraries and helpers when interacting with the vSphere API. Uses govmomi.

Usage

Package client

client provides constructors for vSphere SOAP and REST APIs, and a generic Client which combines the different APIs and useful managers in a single component. All clients are configured with session keep-alive.

The Client can be created with client.New(ctx) and is configured via environment variables (see below) and plain text files for the basic_auth username and password.

See example and the package documentation for details.

Variable Description Required Example Default
VCENTER_URL vCenter Server URL yes https://myvc-01.prod.corp.local ""
VCENTER_INSECURE Ignore vCenter Server certificate warnings no "true" "false"
VCENTER_SECRET_PATH Directory where username and password files are located to retrieve credentials yes "./" "/var/bindings/vsphere"
Use with Kubernetes

Typically this library would be used in containerized environments, e.g. Kubernetes, so the configuration is injected via the application manifest.

# create Kubernetes secret holding the vSphere credentials
kubectl --namespace myapp create secret generic vsphere-credentials --from-literal=username=administrator@vsphere.local --from-literal=password='P@ssW0rd'

A basic application manifest using this library would look similar to this example:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: myapp
  name: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
        - image: <your_image>
          name: app
          env:
            - name: VCENTER_INSECURE
              value: "true"
            - name: VCENTER_URL
              value: "https://myvc-01.prod.corp.local"
            - name: VCENTER_SECRET_PATH
              value: "/var/bindings/vsphere" # this is the default path
          volumeMounts:
            - name: credentials
              mountPath: /var/bindings/vsphere # this is the default path
              readOnly: true
      volumes:
        - name: credentials
          secret:
            secretName: vsphere-credentials

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL