Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
/ vsphere Public archive

Convenience packages and helpers when interacting with vSphere APIs

License

Notifications You must be signed in to change notification settings

embano1/vsphere

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Convenience packages and helpers when interacting with vSphere APIs

Resources

License

Stars

Watchers

Forks

Packages

No packages published