Skip to main content

Profile function for authenticating to VMware CCI

·2 mins
VCF Automation vExpert VMware Script Kubernetes Homelab vSphere CCI LazyOps
Photo by Joan Gamell on Unsplash
You know the saying: “In for a penny…”. Having made a profile function to help with authenticating to VMware VKS, how about one for the CCI plugin now.

The Cloud Consumption Interface (CCI), Local Consumption Interface (LCI), or Consumption Interface (CI?). I have seen it referred to my several names, but at the time of writing the documentation says it’s CCI. Whatever it’s name, it’s a layer that provides an integration between VCF Automation and the Supervisor in vSphere.

Unsuprisingly it has its own plugin for kubectl. And like the one for vSphere it’s not great for the lazy typists amongst us. Even more so in this case because authentication requires a refresh token from VCF Automation so it’s a two-step process.

If you’ve seen my previous post where I created a profile function to help with using the vSphere plugin for kubectl, then it’ll come as no surprise that you can do the same thing for CCI!

So, instead of having to run a curl command to get a token and then supply it to the CCI plugin, you could use the following in your .zshrc (or other) profile to simplify the process:

alias k="kubectl"
export ADM="[email protected]"
export ME="[email protected]"

kcci() {
    case $# in
        0)
            echo "Help for 'kcci':"
            echo ""
            echo "  This function is a shortcut for performing a kubectl cci login. It expects the following positional parameters:"
            echo "    user      - the username used to login"
            echo ""
            ;;
        1)
            echo -n Password:
            read -s password
            refreshtoken=$(curl -X POST "https://automation.lab.mpoore.io/csp/gateway/am/api/login?access_token" -H "Content-Type: application/json" -H "Accept: application/json" -d "{\"username\": \"$1\",\"password\": \"$password\"}" | jq -r .refresh_token)
            kubectl cci login -t $refreshtoken --server automation.lab.mpoore.io --insecure-skip-tls-verify
            ;;
        *)
            echo "WARNING!! Too many arguments supplied!"
            echo ""
            kcci
            ;;
    esac
}

As with the vSphere example, using it is easy:

kcci $ADM

Just provide the password when prompted and you’re in!!!

Related

Profile function for authenticating to VMware VKS
·3 mins
VKS vExpert VMware Script Kubernetes Homelab vSphere Supervisor LazyOps
The vSphere plugin for kubectl allows you to authenticate to VMware VKS clusters with ease, but what if you’re a lazy typist? Lighten the load with this function!
Supervisor cluster running out of disk space in /dev/root
·4 mins
vSphere Supervisor VKS VMware vExpert Homelab Kubernetes
What do you do in the /dev/root filesystem in your Supervisor cluster is running out of room? Log a support request! But there is a short-term fix that I can share.
An introduction to vSphere Supervisor and vSphere Kubernetes Service (VKS)
·5 mins
vSphere Supervisor VKS VMware vExpert Homelab Kubernetes
They’ve gone by many names, and I have been talking about them a fair bit, so I decided to do a quick introduction to the vSphere Supervisor and the vSphere Kubernetes Service (VKS).