• Kubernetes Submit Queue's avatar
    Merge pull request #63902 from vmware/vcp_secrets · 2d1f42e0
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue (batch tested with PRs 63969, 63902, 63689, 63973, 63978). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.
    
    Adds a mechanism in vSphere Cloud Provider to get credentials from Kubernetes secrets
    
    **What this PR does / why we need it**:
    Currently, vCenter credentials are stored in plain text in vsphere.conf. This PR adds a mechanism in vSphere Cloud Provider to get vCenter credentials from Kubernetes secrets.
    
    **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
    Fixes #
    
    **Special notes for your reviewer**:
    Internally review here: https://github.com/vmware/kubernetes/pull/484
    **Workflow:**
    1. Create vsphere.conf file with ```secret-name``` and ```secret-namespace```.
    	```
    	[Global]
    	insecure-flag = 1
    	secret-name = "vcconf"
    	secret-namespace = "kube-system"
    
    	[VirtualCenter "10.160.45.119"]
    	port = 443
    	datacenters = k8s-dc-1
    
    	[Workspace]
    	server = 10.160.45.119
    	datacenter = k8s-dc-1
    	default-datastore = sharedVMFS-0
    	folder = Discovered virtual machine
    	```
    2. Launch Kubernetes cluster with vSphere Cloud Provider Configured.
    3. Create secret with vCenter credentials.
    	a. Create base64 encoding for username and password:
    	username:
    	```	
    		> echo -n 'admin' | base64
    		YWRtaW4= 
    	```
    	password:
    	```
    		> echo -n 'vsphere' | base64
    		dnNwaGVyZQ==
    	```
    
    	b. kubectl create -f vccredentials.yaml
    	```
    		#vccredentials.yaml
    		apiVersion: v1
    		kind: Secret
    		metadata:
    			name: vcconf
    		type: Opaque
    		data:
    			10.192.44.199.username: YWRtaW4=
    			10.192.44.199.password: dnNwaGVyZQ==
    	```
    4. vSphere Cloud Provider can be used now.
    
    **Note:**
    Secrets info can be provided with both (old and new) vSphere Cloud provider configuration formats.
    
    
    **Tests Done:**
    - [x] vSphere Cloud Provider unit test.
    - [x] Volume lifecyle with Username and Password in vsphere.conf (for backward compability)
    - [x] Volume lifecyle with secrets information in vsphere.conf.
    - [x] Update secrets workflow
    
    **Release note**:
    
    ```release-note
    Adds a mechanism in vSphere Cloud Provider to get credentials from Kubernetes secrets
    ```
    2d1f42e0
Name
Last commit
Last update
..
providers Loading commit data...
BUILD Loading commit data...
OWNERS Loading commit data...
README.md Loading commit data...
cloud.go Loading commit data...
doc.go Loading commit data...
plugins.go Loading commit data...