Skip to content
This repository has been archived by the owner on Dec 18, 2020. It is now read-only.

For internal review only #41

Open
wants to merge 41 commits into
base: review-base
Choose a base branch
from
Open

For internal review only #41

wants to merge 41 commits into from

Conversation

luomiao
Copy link

@luomiao luomiao commented Apr 10, 2017

DON'T MERGE!

This is a review for vSphere support code in kops before upstreaming.
Please refer the following guide for an easier review :)

For those who never use or read about kops before, the following docs might be helpful for a high-level understanding:
https://github.com/kubernetes/kops/blob/master/docs/development/how_it_works.md
https://github.com/kubernetes/kops/blob/master/docs/philosophy.md
About how to use kops with AWS:
https://github.com/kubernetes/kops/blob/master/docs/aws.md
About how to use kops on vSphere:
https://github.com/vmware/kops/blob/vsphere-develop/docs/development/vsphere-dev.md

The changes to support vSphere mainly include 5 parts:

  1. Cloud Specs: add vSphere as one of the Cloud Providers. Currently AWS and GCE are the only two Cloud Providers in kops.
  2. Cloudup: Cloudup is the entry of kops core logics. Cloudup created builders for different models and include tasks into models. pkg/model/vspheremodel and upup/pkg/fi/cloudup/vspheretasks to initialize vSphere specific tasks, including clone VMs/poweron VMs/AttachISOs, and so on.
  3. Nodeup: Nodeup is a binary will be started on each nodes. It's used to bootstrap the whole k8s cluster. It will also start protokube.
  4. Protokube: Protokube is a docker container started at the very beginning to ensure the environment of kubelet is ready. More introduction about protokube can be found here.
  5. DNS: We use CoreDNS. The steps to setup CoreDNS can be found in here. In order to use CoreDNS, changes are needed for Nodeup/Protokube and DNS Controller addon.

SandeepPissay and others added 24 commits April 10, 2017 17:12
Accept vSphere's server, datacenter, cluster setting by flags
"vsphere-server", "vsphere-datacenter", and "vsphere-resource-pool".
Username and password can be set by environment variables:
"VSPHERE_USERNAME" and "VSPHERE_PASSWORD".
1. Check the emptiness of VSPHERE_USERNAME and VSPHERE_PASSWORD
2. Move vSphere specific fields from clusterSpec to clusterSpec.CloudConfig
…ed conversion files.

To make sure the vSphere fields in CloudConfiguration can be successfully serialized
and output into config file.
Implemented CreateLinkClonedVM cloud interface to create a link cloned VM from a template VM. The code checks if the template VM has a snapshot, if no it creates it before creating a link cloned VM. If snapshot already exists, it uses it to create the link cloned VM.

Testing done:
1. kops cluster create goes through fine and creates the link cloned VM for the master and worker. Verified that it creates the snapshot on the template VM if it does not exists before creating a link cloned VM. In case the snapshot exists, it uses it to create the link cloned VM.
2. "make ci" is successful.
…akefile. (#1)

* Add vSphere volumes to protokube. Update vSphere testing doc and makefile.

* Updated vsphere_volume to get correct IP. Addressed comments.
* Add support of CoreDNS for vSphere provider.

* Add instructions about how to setup CoreDNS for vSphere provider.

* Address comments for CoreDNS support code.
AttachISO task creates the user-data/meta-data cloud init files and creates cloud-init.iso file using "genisoimage" tool. It then uploads it to the datastore where the master/worker VM resides and inserts it into the cd-rom device of the master/worker VM. When the master/worker VM powers on, the cloud-init package in it runs the bootstrap script that downloads nodeup and runs it.

Also removed redundant VirtualMachineModelBuilder that does nothing.

Testing done:
1. Tested end to end that the master and worker VMs executes the cloud-init script successfully.
2, "make ci" is successful.
* Enable CoreDNS in nodeup/protokube.

* Address comments.
…vSphere VM (#11)

* Added code to enable nodeup and protokube building and execution for vSphere VM.

* Fixed nodeup template for vSphere.
Copy link

@pdhamdhere pdhamdhere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid for first draft. Terrific work everyone!

Some minor comments, mostly clarifying questions. We can discuss in-person as well.

Few general suggestions:

  1. Add file header comments with purpose of code in that file.
  2. Add function header comments for exported functions (that will be called from outside)
  3. Did we run golint?

@@ -202,6 +213,14 @@ func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command {
cmd.Flags().StringVar(&options.MasterTenancy, "master-tenancy", options.MasterTenancy, "The tenancy of the master group on AWS. Can either be default or dedicated.")
cmd.Flags().StringVar(&options.NodeTenancy, "node-tenancy", options.NodeTenancy, "The tenancy of the node group on AWS. Can be either default or dedicated.")

if featureflag.VSphereCloudProvider.Enabled() {
// vSphere flags
cmd.Flags().StringVar(&options.VSphereServer, "vsphere-server", options.VSphereServer, "vsphere-server is required for vSphere. Set vCenter URL Ex: 10.192.10.30 or myvcenter.io (without https://)")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Port? I believe we had customer using kube-anywhere with vCenter running on different port. CHeck with Divyen.

Copy link
Author

@luomiao luomiao Apr 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No the vCenter port is not necessary. And it has been deprecated after this PR:
https://github.com/kubernetes/kubernetes/pull/42024/files
Even without the port there is no problem to talk to vCenter.
The kube-anywhere readme should be updated too.

cmd.Flags().StringVar(&options.VSphereDatacenter, "vsphere-datacenter", options.VSphereDatacenter, "vsphere-datacenter is required for vSphere. Set the name of the datacenter in which to deploy Kubernetes VMs.")
cmd.Flags().StringVar(&options.VSphereResourcePool, "vsphere-resource-pool", options.VSphereDatacenter, "vsphere-resource-pool is required for vSphere. Set a valid Cluster, Host or Resource Pool in which to deploy Kubernetes VMs.")
cmd.Flags().StringVar(&options.VSphereCoreDNSServer, "vsphere-coredns-server", options.VSphereCoreDNSServer, "vsphere-coredns-server is required for vSphere.")
cmd.Flags().StringVar(&options.VSphereDatastore, "vsphere-datastore", options.VSphereDatastore, "vsphere-datastore is required for vSphere. Set a valid datastore in which to store dynamic provision volumes.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is optional rt?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The datastore field seems is necessary for v1.5.3 support. @abrarshivani Hi Abrar, can you confirm this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current stable versions for vSphere Cloud Provider requires datastore

}
cluster.Spec.CloudConfig.VSphereCoreDNSServer = fi.String(c.VSphereCoreDNSServer)

if c.VSphereDatastore == "" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is optional rt?

}

if dnsRecord != nil && string(dnsRecord.Type()) == string(k.RecordType) {
glog.V(8).Infof("Found matching record: %s %s", k.RecordType, fqdn)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move it to just before cs.Remove and change to glog.V(2) and "Deleting resource record: ..." to be consistent with AWS L495

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

### Pre-requisites
+ vSphere with at least one ESX, having sufficient free disk space on attached datastore. ESX VM's should have internet connectivity.
+ Setup DNS following steps given in relevant Section above.
+ Create the VM using this template (TBD).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steps?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

defaultNodeMachineTypeGCE = "n1-standard-2"
defaultNodeMachineTypeAWS = "t2.medium"
defaultNodeMachineTypeGCE = "n1-standard-2"
defaultNodeMachineTypeVSphere = "vsphere_node"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is configuration of node defined?

defaultMasterMachineTypeAWS = "m3.medium"
defaultMasterMachineTypeVSphere = "vsphere_master"

defaultVSphereNodeImage = "ubuntu_16_04"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see AMI Id for AWS then why do we have vSphereNodeImage here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prashima Now we can use --image to define the image to be used. Do we still need defaultVSphereNodeImage?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to fix default image name extraction for vSphere. Here is the relevant issue #50.

We can remove this default image from here, but note that that will make '--image' a mandatory flag for vSphere cluster create operation.

export KOPS_FEATURE_FLAGS=+VSphereCloudProvider

# If set, coredns will be used for vsphere cloud provider.
export VSPHERE_DNS=coredns

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You already have CLI option "--dns=private --vsphere-coredns-server" so do we still need these environment variable?


func (c *VSphereCloud) DNS() (dnsprovider.Interface, error) {
// TODO: this is a temporary flag to toggle between CoreDNS and Route53, before CoreDNS is stable
dns_provider := os.Getenv("VSPHERE_DNS")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We pass this info to KOPS CLI rt? Why do we need env variable?

lines = append(lines, " echo \"nameserver "+dnsHost+"\" >> /etc/resolvconf/resolv.conf.d/head")
lines = append(lines, " resolvconf -u")
dnsUpdateStr := strings.Join(lines, "\n")
data = strings.Replace(data, "$DNS_SCRIPT", dnsUpdateStr, -1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use sprintf or equivalent rather than strings.XXX???

Makefile Outdated
# Build protokube and nodeup. Pushes protokube to DOCKER_REGISTRY and scp nodeup binary to the TARGET. Uncomment ssh part to run nodeup at set TARGET.
push-vsphere: nodeup protokube-push
scp -C .build/dist/nodeup ${TARGET}:~/
# ssh -t [email protected] 'export AWS_ACCESS_KEY_ID="AKIAJ6UOKB6BGYLIQJEQ"; export AWS_SECRET_ACCESS_KEY="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"; export AWS_REGION="us-west-2"; SKIP_PACKAGE_UPDATE=1 ~/nodeup --conf=/var/cache/kubernetes-install/kube_env.yaml --v=8'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "push-vsphere" is not needed anymore rt? @prashima

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants