diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 545ed3606a73..0b236ec98297 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -70,7 +70,7 @@ You can find an example implementation for GCE [here](https://github.com/kuberne ##### GCE Implementation -For GCE, a [yaml file](https://github.com/kubernetes-sigs/cluster-api/blob/master/gcp-deployer/machine_setup_configs.yaml) holds the list of valid machine setup configs, +For GCE, a [config map](https://github.com/kubernetes-sigs/cluster-api/blob/6aecf9c80a1ca29b45cb43ebfd50ac0d57eb7132/clusterctl/examples/google/provider-components.yaml.template#L118) holds the list of valid machine setup configs, and the yaml file is volume mounted into the machine controller using a ConfigMap named `machine-setup`. A [config type](https://github.com/kubernetes-sigs/cluster-api/blob/master/cloud/google/machinesetup/config_types.go#L45) defines a set of parameters that can be taken from the machine object being created, and maps those parameters to startup scripts and other relevant information. diff --git a/README.md b/README.md index 41e9554bd4b7..a5dfc3133a53 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,8 @@ To learn more, see the [Cluster API KEP][cluster-api-kep]. ## Getting Started ### Prerequisites * `kubectl` is required, see [here](http://kubernetes.io/docs/user-guide/prereqs/). - -### Prototype implementations -* [gcp](gcp-deployer/README.md) - +* `clusterctl` is a SIG-cluster-lifecycle sponsored tool to manage Cluster API clusters. See [here](clusterctl) + ## How to use the API To see how to build tooling on top of the Cluster API, please check out a few examples below: diff --git a/cloud/vsphere/machineactuator.go b/cloud/vsphere/machineactuator.go index 8e5195a8a8ba..b6f537b11d39 100644 --- a/cloud/vsphere/machineactuator.go +++ b/cloud/vsphere/machineactuator.go @@ -28,13 +28,10 @@ import ( "github.com/golang/glog" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" "encoding/base64" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/kubernetes" "sigs.k8s.io/cluster-api/cloud/vsphere/namedmachines" vsphereconfig "sigs.k8s.io/cluster-api/cloud/vsphere/vsphereproviderconfig" vsphereconfigv1 "sigs.k8s.io/cluster-api/cloud/vsphere/vsphereproviderconfig/v1alpha1" @@ -94,40 +91,6 @@ func NewMachineActuator(kubeadmToken string, machineClient client.MachineInterfa }, nil } -// DEPRECATED: Remove when vsphere-deployer is deleted. -func (vc *VsphereClient) CreateMachineController(cluster *clusterv1.Cluster, initialMachines []*clusterv1.Machine, clientSet kubernetes.Clientset) error { - if err := CreateExtApiServerRoleBinding(); err != nil { - return err - } - - // Create the named machines ConfigMap. - // After pivot-based bootstrap is done, the named machine should be a ConfigMap and this logic will be removed. - namedMachines, err := vc.namedMachineWatch.NamedMachines() - - if err != nil { - return err - } - yaml, err := namedMachines.GetYaml() - if err != nil { - return err - } - nmConfigMap := corev1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{Name: "named-machines"}, - Data: map[string]string{ - NamedMachinesFilename: yaml, - }, - } - configMaps := clientSet.CoreV1().ConfigMaps(corev1.NamespaceDefault) - if _, err := configMaps.Create(&nmConfigMap); err != nil { - return err - } - - if err := CreateApiServerAndController(vc.kubeadmToken); err != nil { - return err - } - return nil -} - func saveFile(contents, path string, perm os.FileMode) error { return ioutil.WriteFile(path, []byte(contents), perm) } @@ -669,42 +632,6 @@ func (vc *VsphereClient) GetKubeConfig(master *clusterv1.Machine) (string, error return result, nil } -// DEPRECATED. Remove after vsphere-deployer is deleted. -// This method exists because during bootstrap some artifacts need to be transferred to the -// remote master. These include the IP address for the master, terraform state file. -// In GCE, we set this kind of data as GCE metadata. Unfortunately, vSphere does not have -// a comparable API. -func (vc *VsphereClient) SetupRemoteMaster(master *clusterv1.Machine) error { - machineName := master.ObjectMeta.Name - glog.Infof("Setting up the remote master[%s] with terraform config.", machineName) - - ip, err := vc.GetIP(master) - if err != nil { - return err - } - - glog.Infof("Copying the staging directory to master.") - machinePath := fmt.Sprintf(MachinePathStageFormat, machineName) - _, err = vc.remoteSshCommand(master, fmt.Sprintf("mkdir -p %s", machinePath), "~/.ssh/vsphere_tmp", "ubuntu") - if err != nil { - glog.Infof("remoteSshCommand failed while creating remote machine stage: %+v", err) - return err - } - - cmd := exec.Command( - "scp", "-i", "~/.ssh/vsphere_tmp", - "-o", "StrictHostKeyChecking=no", - "-o", "UserKnownHostsFile=/dev/null", - "-r", - machinePath, - fmt.Sprintf("ubuntu@%s:%s", ip, StageDir)) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Run() - - return nil -} - // We are storing these as annotations and not in Machine Status because that's intended for // "Provider-specific status" that will usually be used to detect updates. Additionally, // Status requires yet another version API resource which is too heavy to store IP and TF state. diff --git a/clusterctl/main_integration_test.go b/clusterctl/main_integration_test.go index b5026f1d1b9d..7275c107a512 100644 --- a/clusterctl/main_integration_test.go +++ b/clusterctl/main_integration_test.go @@ -149,7 +149,7 @@ func setupPrerequisites() error { } err = cleanAndBuildClusterctl() if err != nil { - return fmt.Errorf("unable to build gcp-deployer: %v", err) + return fmt.Errorf("unable to build clusterctl: %v", err) } return nil } diff --git a/tf-deployer/.gitignore b/tf-deployer/.gitignore deleted file mode 100644 index b33d73ed6924..000000000000 --- a/tf-deployer/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -machines.yaml -tf-deployer diff --git a/tf-deployer/CONTRIBUTING.md b/tf-deployer/CONTRIBUTING.md deleted file mode 100644 index 8e364f89d035..000000000000 --- a/tf-deployer/CONTRIBUTING.md +++ /dev/null @@ -1,136 +0,0 @@ -# Contributing Guidelines - -## Prerequisites - -### Install terraform - -Install terraform as per [instructions](https://www.terraform.io/intro/getting-started/install.html) or use the provided binary (`cluster-api/cloud/terraform/bin/terraform`). - -### Install Google Cloud SDK (gcloud) - -Google Cloud SDK (gcloud) will be helpful for setting credentials to push the controller image to GCR. - -Steps to follow: -1. Install as per [Cloud SDK instructions](https://cloud.google.com/sdk/); -2. Configure Cloud SDK to point to the GCP project you will be using. - - ```bash - $ gcloud config set project - ``` - -### Set GCP Credentials - -In order to develop the TF machine controller, you need to configure the credentials to push a newer version of the controller to GCR. - -You can set it in two ways, as explained below. - -#### Environment Variable GOOGLE_APPLICATION_CREDENTIALS - -Steps to follow: -1. Verify that the environment variable `GOOGLE_APPLICATION_CREDENTIALS` is set pointing to valid service account credentials -2. If not set, follow the [instructions on Google Cloud Platform site](https://cloud.google.com/docs/authentication/getting-started) to have it set up. - -#### Login Using Cloud SDK - -The alternative is to set the client credentials via gcloud by executing the command line below. - -```bash -$ gcloud auth application-default login -``` - -### Install Docker - -1. Install [Docker](https://docs.docker.com/install/) on your machine; -2. Make sure your user can execute docker commmands (without sudo). This is a way to test it: -```bash -$ docker run hello-world - -Hello from Docker! -This message shows that your installation appears to be working correctly. -... -``` - -3. Run `gcloud beta auth configure-docker` to configure your credentials. - -### Install OpenSSL - -Install [OpenSSL](https://www.openssl.org/source/) on your machine. Please note that this is just temporary. We are working to remove this dependency. See [Issue](https://github.com/kubernetes/kube-deploy/issues/591) - -## Fetch Source Code - -1. Fork [cluster-api repo](https://github.com/kubernetes-sigs/cluster-api). If it's your first time forking, please take a look at [GitHub Repo instructions](https://help.github.com/articles/fork-a-repo/). The general [Kubernetes GitHub workflow](https://github.com/kubernetes/community/blob/master/contributors/guide/github-workflow.md) is helpful here too if you're getting started. - -2. Clone Repo Locally -```bash -$ cd $GOPATH/src/sigs.k8s.io/ -$ git clone https://github.com//cluster-api.git -``` - -## Build - -```bash -$ cd $GOPATH/src/sigs.k8s.io/cluster-api/tf-deployer/ -$ go build -``` - -This will create a binary `tf-deployer` in the same directory. You can use that binary to manage a cluster. - -## Developing - -When making changes to the machine controller, it's generally a good idea to delete any existing cluster created with an older version of the cluster-api. - -Note: the below command is not yet implemented. - -```bash -$ ./tf-deployer delete -``` - -After making changes to the controllers or the actuator, you need to follow these two steps: - -1. Rebuild the machine-controller image. Also change `machineControllerImage` in `cloud/terraform/pods.go` to the new image path (make sure the version in the Makefile and `pods.go` match if you want to use the new image). Then, rebuild and push the image. - - ```bash - $ cd $GOPATH/src/sigs.k8s.io/cluster-api/cloud/terraform/cmd/terraform-machine-controller - $ make dev_push - ``` - -NOTE: that the image will be pushed to `gcr.io/$GCP_PROJECT/terraform-machine-controller`. Image storage is a billable resource. - -2. Rebuild tf-deployer - - ```bash - $ cd $GOPATH/src/sigs.k8s.io/cluster-api/tf-deployer/ - $ go build - ``` - -The new `†f-deployer` will have your changes. - -## Testing - -We do not have unit tests or integration tests currently. For any changes, it is recommended that you test a create-edit-delete sequence using the new machine controller image and the new `tf-deployer` binary. - -1. Generate machines configuration file. - -1. Create a cluster - - ```bash - $ ./tf-deployer create -c cluster.yaml -m machines.yaml -n vsphere_named_machines.yaml - ``` - -[Optional]To verify API server has been deployed successfully, you can the following command to double check. - - ```bash - $ kubectl get apiservices v1alpha1.cluster.k8s.io -o yaml - ``` - -2. Edit the machine to trigger an update - - ```bash - $ kubectl edit machine $MACHINE_NAME - ``` - -3. Make sure the new behavior is working as intended. Then delete the cluster. - - ```bash - $ ./tf-deployer delete - ``` diff --git a/tf-deployer/README.md b/tf-deployer/README.md deleted file mode 100644 index e68b381648a6..000000000000 --- a/tf-deployer/README.md +++ /dev/null @@ -1,82 +0,0 @@ -# Cluster API Terraform Prototype for vSphere 6.5 - -The Cluster API Terraform prototype implements the [Cluster API](https://github.com/kubernetes-sigs/cluster-api/blob/master/README.md) for Terraform. The target provider for this prototype is vSphere 6.5. - -## Getting Started - -### Prerequisites - -Follow the steps listed at [CONTRIBUTING.md](https://github.com/kubernetes-sigs/cluster-api/blob/master/tf-deployer/CONTRIBUTING.md) to: - -1. Build the `tf-deployer` tool - ``` - cd $GOPATH/src/sigs.k8s.io/cluster-api/tf-deployer/ - go build - ``` -1. Create a vSphere template following [this guide](https://blog.inkubate.io/deploy-a-vmware-vsphere-virtual-machine-with-terraform/) up to **Create the vSphere Ubuntu 16.04 template** section. -1. Create a resource pool for your cluster. -1. Create a pair of ssh keys that will be used to connect to the VMs. Put your - keys in `~/.ssh/vsphere_tmp` and `~/.ssh/vsphere_tmp.pub`. - ``` - ssh-keygen -b 2048 -t rsa -f ~/.ssh/vsphere_tmp -q -N "" - ``` -1. Create a `machines.yaml` file configured for your cluster. See the provided template - for an example, if you use it, make sure to fill in all missing `terraformVariables` - in `providerConfig`. - -### Limitation - -See [here](https://github.com/karan/kube-deploy/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+vsphere). - -### Creating a cluster - -1. Create a cluster: - ``` - ./tf-deployer create -c cluster.yaml -m machines.yaml -n vsphere_named_machines.yaml - ``` - -During cluster creation, you can watch the machine resources get created in Kubernetes, -see the corresponding virtual machines created in your provider, and then finally see nodes -join the cluster: - -```bash -$ watch -n 5 "kubectl get machines" -$ watch -n 5 "kubectl get nodes" -``` - - -### Interacting with your cluster - -Once you have created a cluster, you can interact with the cluster and machine -resources using kubectl: - -``` -$ kubectl get clusters -$ kubectl get machines -$ kubectl get machines -o yaml -``` - -#### Scaling your cluster - -**NOT YET SUPPORTED!** - -#### Upgrading your cluster - -**NOT YET SUPPORTED!** - -#### Node repair - -**NOT YET SUPPORTED!** - -### Deleting a cluster - -**NOT YET SUPPORTED!** - -### How does the prototype work? - -Right now, the Cluster and Machine objects are stored as resources in an extension apiserver, which -connected with main apiserver through api aggregation. We deploy the extension API server and -controller manager as a pod inside the cluster. Like other resources in Kubernetes, machine -controller as part of controller manager is responsible to reconcile the actual vs. desired machine -state. Bootstrapping and in-place upgrading is handled by -[kubeadm](https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/). diff --git a/tf-deployer/cluster.yaml b/tf-deployer/cluster.yaml deleted file mode 100644 index 7d211634e0f7..000000000000 --- a/tf-deployer/cluster.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: "cluster.k8s.io/v1alpha1" -kind: Cluster -metadata: - name: test1 -spec: - clusterNetwork: - services: - cidrBlocks: ["10.96.0.0/12"] - pods: - cidrBlocks: ["192.168.0.0/16"] - serviceDomain: "cluster.local" - providerConfig: - value: - apiVersion: "terraformproviderconfig/v1alpha1" - kind: "TerraformProviderConfig" \ No newline at end of file diff --git a/tf-deployer/cmd/add.go b/tf-deployer/cmd/add.go deleted file mode 100644 index 344a51df52b4..000000000000 --- a/tf-deployer/cmd/add.go +++ /dev/null @@ -1,63 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cmd - -import ( - "os" - - "github.com/golang/glog" - "github.com/spf13/cobra" - "sigs.k8s.io/cluster-api/tf-deployer/deploy" -) - -type AddOptions struct { - Machine string -} - -var ao = &AddOptions{} - -var addCmd = &cobra.Command{ - Use: "add", - Short: "Add nodes to cluster", - Long: `Add nodes to cluster`, - Run: func(cmd *cobra.Command, args []string) { - if ao.Machine == "" { - glog.Error("Please provide yaml file for machine definition.") - cmd.Help() - os.Exit(1) - } - if err := RunAdd(ao); err != nil { - glog.Exit(err) - } - }, -} - -func RunAdd(ao *AddOptions) error { - machines, err := parseMachinesYaml(ao.Machine) - if err != nil { - return err - } - - d := deploy.NewDeployer(kubeConfig, "") - - return d.AddNodes(machines) -} -func init() { - addCmd.Flags().StringVarP(&ao.Machine, "machines", "m", "", "machine yaml file") - - RootCmd.AddCommand(addCmd) -} diff --git a/tf-deployer/cmd/create.go b/tf-deployer/cmd/create.go deleted file mode 100644 index ecf4ab10b2d8..000000000000 --- a/tf-deployer/cmd/create.go +++ /dev/null @@ -1,83 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cmd - -import ( - "os" - - "fmt" - "github.com/golang/glog" - "github.com/spf13/cobra" - "sigs.k8s.io/cluster-api/tf-deployer/deploy" -) - -type CreateOptions struct { - Cluster string - Machine string - NamedMachinePath string -} - -var co = &CreateOptions{} - -var createCmd = &cobra.Command{ - Use: "create", - Short: "Create kubernetes cluster", - Long: `Create a kubernetes cluster with one command`, - Run: func(cmd *cobra.Command, args []string) { - if co.Cluster == "" { - glog.Error("Please provide yaml file for cluster definition.") - cmd.Help() - os.Exit(1) - } - if co.Machine == "" { - glog.Error("Please provide yaml file for machine definition.") - cmd.Help() - os.Exit(1) - } - if co.NamedMachinePath == "" { - glog.Error("Please provide a yaml file for machine HCL configs.") - cmd.Help() - os.Exit(1) - } - if err := RunCreate(co); err != nil { - glog.Exit(err) - } - }, -} - -func RunCreate(co *CreateOptions) error { - cluster, err := parseClusterYaml(co.Cluster) - if err != nil { - return fmt.Errorf("Error parsing cluster yaml: %+v", err) - } - - machines, err := parseMachinesYaml(co.Machine) - if err != nil { - return fmt.Errorf("Error parsing machines yaml: %+v", err) - } - - d := deploy.NewDeployer(kubeConfig, co.NamedMachinePath) - - return d.CreateCluster(cluster, machines) -} -func init() { - createCmd.Flags().StringVarP(&co.Cluster, "cluster", "c", "", "cluster yaml file") - createCmd.Flags().StringVarP(&co.Machine, "machines", "m", "", "machine yaml file") - createCmd.Flags().StringVarP(&co.NamedMachinePath, "namedmachines", "n", "", "named machines yaml file") - - RootCmd.AddCommand(createCmd) -} diff --git a/tf-deployer/cmd/delete.go b/tf-deployer/cmd/delete.go deleted file mode 100644 index cfeaaa90f633..000000000000 --- a/tf-deployer/cmd/delete.go +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cmd - -import ( - "github.com/golang/glog" - "github.com/spf13/cobra" - "sigs.k8s.io/cluster-api/tf-deployer/deploy" -) - -var deleteCmd = &cobra.Command{ - Use: "delete", - Short: "Delete kubernetes cluster", - Long: `Delete a kubernetes cluster with one command`, - Run: func(cmd *cobra.Command, args []string) { - if err := RunDelete(); err != nil { - glog.Exit(err) - } - }, -} - -func RunDelete() error { - d := deploy.NewDeployer(kubeConfig, "") - return d.DeleteCluster() -} - -func init() { - RootCmd.AddCommand(deleteCmd) -} diff --git a/tf-deployer/cmd/root.go b/tf-deployer/cmd/root.go deleted file mode 100644 index 0f4067b2b435..000000000000 --- a/tf-deployer/cmd/root.go +++ /dev/null @@ -1,85 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cmd - -import ( - "flag" - "io/ioutil" - - "github.com/ghodss/yaml" - "github.com/golang/glog" - "github.com/spf13/cobra" - "k8s.io/apiserver/pkg/util/logs" - clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" - "sigs.k8s.io/cluster-api/util" -) - -var RootCmd = &cobra.Command{ - Use: "tf-deployer", - Short: "cluster management", - Long: `Simple kubernetes cluster management`, - Run: func(cmd *cobra.Command, args []string) { - // Do Stuff Here - cmd.Help() - }, -} - -var ( - kubeConfig string -) - -func Execute() { - if err := RootCmd.Execute(); err != nil { - glog.Exit(err) - } -} - -func parseClusterYaml(file string) (*clusterv1.Cluster, error) { - bytes, err := ioutil.ReadFile(file) - if err != nil { - return nil, err - } - - cluster := &clusterv1.Cluster{} - err = yaml.Unmarshal(bytes, cluster) - if err != nil { - return nil, err - } - - return cluster, nil -} - -func parseMachinesYaml(file string) ([]*clusterv1.Machine, error) { - bytes, err := ioutil.ReadFile(file) - if err != nil { - return nil, err - } - - machines := &clusterv1.MachineList{} - err = yaml.Unmarshal(bytes, &machines) - if err != nil { - return nil, err - } - - return util.MachineP(machines.Items), nil -} - -func init() { - RootCmd.PersistentFlags().StringVarP(&kubeConfig, "kubeconfig", "k", "", "location for the kubernetes config file. If not provided, $HOME/.kube/config is used") - flag.CommandLine.Parse([]string{}) - logs.InitLogs() -} diff --git a/tf-deployer/deploy/deploy.go b/tf-deployer/deploy/deploy.go deleted file mode 100644 index 26cbb2e9779e..000000000000 --- a/tf-deployer/deploy/deploy.go +++ /dev/null @@ -1,138 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package deploy - -import ( - "fmt" - "os" - "strings" - - "github.com/golang/glog" - "k8s.io/client-go/kubernetes" - "sigs.k8s.io/cluster-api/cloud/terraform" - clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" - "sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset" - "sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1" - "sigs.k8s.io/cluster-api/util" - apiutil "sigs.k8s.io/cluster-api/util" -) - -type deployer struct { - token string - configPath string - machineDeployer machineDeployer - client v1alpha1.ClusterV1alpha1Interface - clientSet clientset.Interface - kubernetesClientSet kubernetes.Clientset -} - -// NewDeployer returns a cloud provider specific deployer and -// sets kubeconfig path for the cluster to be deployed -func NewDeployer(configPath, namedMachinesPath string) *deployer { - token := util.RandomToken() - if configPath == "" { - configPath = os.Getenv("KUBECONFIG") - if configPath == "" { - configPath = apiutil.GetDefaultKubeConfigPath() - } else { - // KUBECONFIG could hold more than one path. - configPath = strings.Split(configPath, ":")[0] - } - } else { - // This is needed for kubectl commands run later to create secret in function - // CreateMachineControllerServiceAccount - if err := os.Setenv("KUBECONFIG", configPath); err != nil { - glog.Exit(fmt.Sprintf("Failed to set Kubeconfig path err %v\n", err)) - } - } - ma, err := terraform.NewMachineActuator(token, nil, namedMachinesPath) - if err != nil { - glog.Exit(err) - } - return &deployer{ - token: token, - machineDeployer: ma, - configPath: configPath, - } -} - -func (d *deployer) CreateCluster(c *clusterv1.Cluster, machines []*clusterv1.Machine) error { - vmCreated := false - if err := d.createCluster(c, machines, &vmCreated); err != nil { - if vmCreated { - d.deleteMasterVM(c, machines) - } - d.machineDeployer.PostDelete(c, machines) - return err - } - - glog.Infof("The [%s] cluster has been created successfully!", c.Name) - glog.Info("You can now `kubectl get nodes`") - return nil -} - -func (d *deployer) AddNodes(machines []*clusterv1.Machine) error { - if err := d.createMachines(machines); err != nil { - return err - } - return nil -} - -func (d *deployer) DeleteCluster() error { - if err := d.initApiClient(); err != nil { - return err - } - - machines, err := d.listMachines() - if err != nil { - return err - } - - cluster, err := d.getCluster() - if err != nil { - return err - } - - glog.Info("Deleting machine objects") - if err := d.deleteAllMachines(); err != nil { - return err - } - - if err := d.deleteMasterVM(cluster, machines); err != nil { - glog.Errorf("Error deleting master vm", err) - } - - glog.Info("Running post delete operations") - if err := d.machineDeployer.PostDelete(cluster, machines); err != nil { - return err - } - glog.Infof("Deletion complete") - return nil -} - -func (d *deployer) deleteMasterVM(cluster *clusterv1.Cluster, machines []*clusterv1.Machine) error { - master := util.GetMaster(machines) - if master == nil { - return fmt.Errorf("error deleting master vm, no master found") - } - - glog.Infof("Deleting master vm %s", master.Name) - if err := d.machineDeployer.Delete(cluster, master); err != nil { - return err - } - return nil -} diff --git a/tf-deployer/deploy/deploy_helper.go b/tf-deployer/deploy/deploy_helper.go deleted file mode 100644 index 59e17dac3126..000000000000 --- a/tf-deployer/deploy/deploy_helper.go +++ /dev/null @@ -1,300 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package deploy - -import ( - "crypto/tls" - "fmt" - "net/http" - "os" - "time" - - "github.com/golang/glog" - apiv1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" - "sigs.k8s.io/cluster-api/util" -) - -const ( - MasterIPAttempts = 40 - SleepSecondsPerAttempt = 5 - ServiceAccountNs = "kube-system" - ServiceAccountName = "default" -) - -func (d *deployer) createCluster(c *clusterv1.Cluster, machines []*clusterv1.Machine, vmCreated *bool) error { - if c.GetName() == "" { - return fmt.Errorf("cluster name must be specified for cluster creation") - } - master := util.GetMaster(machines) - if master == nil { - return fmt.Errorf("master spec must be provided for cluster creation") - } - - if master.GetName() == "" && master.GetGenerateName() == "" { - return fmt.Errorf("master name must be specified for cluster creation") - } - - if master.GetName() == "" { - master.Name = master.GetGenerateName() + c.GetName() - } - - glog.Infof("Starting cluster creation %s", c.GetName()) - - glog.Infof("Starting master creation %s", master.GetName()) - - if err := d.machineDeployer.Create(c, master); err != nil { - return err - } - - *vmCreated = true - glog.Infof("Created master %s", master.GetName()) - - masterIP, err := d.getMasterIP(master) - if err != nil { - return fmt.Errorf("unable to get master IP: %v", err) - } - - if err := d.machineDeployer.SetupRemoteMaster(master); err != nil { - return fmt.Errorf("unable to setup the master: %v", err) - } - - if err := d.copyKubeConfig(master); err != nil { - return fmt.Errorf("unable to write kubeconfig: %v", err) - } - - if err := d.waitForApiserver(masterIP); err != nil { - return fmt.Errorf("apiserver never came up: %v", err) - } - - if err := d.initApiClient(); err != nil { - return err - } - - if err := d.waitForServiceAccount(); err != nil { - return fmt.Errorf("service account %s/%s not found: %v", ServiceAccountNs, ServiceAccountName, err) - } - - glog.Info("Deploying the addon apiserver and controller manager...") - if err := d.machineDeployer.CreateMachineController(c, machines, d.kubernetesClientSet); err != nil { - return fmt.Errorf("can't create machine controller: %v", err) - } - - if err := d.waitForClusterResourceReady(); err != nil { - return err - } - - c, err = d.client.Clusters(apiv1.NamespaceDefault).Create(c) - if err != nil { - return err - } - - c.Status.APIEndpoints = append(c.Status.APIEndpoints, - clusterv1.APIEndpoint{ - Host: masterIP, - Port: 443, - }) - if _, err := d.client.Clusters(apiv1.NamespaceDefault).UpdateStatus(c); err != nil { - return err - } - - if err := d.createMachines(machines); err != nil { - return err - } - return nil -} - -func (d *deployer) waitForClusterResourceReady() error { - err := util.Poll(500*time.Millisecond, 120*time.Second, func() (bool, error) { - _, err := d.clientSet.Discovery().ServerResourcesForGroupVersion("cluster.k8s.io/v1alpha1") - if err == nil { - return true, nil - } - return false, nil - }) - - return err -} - -func (d *deployer) createMachines(machines []*clusterv1.Machine) error { - for _, machine := range machines { - m, err := d.client.Machines(apiv1.NamespaceDefault).Create(machine) - if err != nil { - return err - } - glog.Infof("Added machine [%s]", m.Name) - } - return nil -} - -func (d *deployer) createMachine(m *clusterv1.Machine) error { - return d.createMachines([]*clusterv1.Machine{m}) -} - -func (d *deployer) deleteAllMachines() error { - machines, err := d.client.Machines(apiv1.NamespaceDefault).List(metav1.ListOptions{}) - if err != nil { - return err - } - for _, m := range machines.Items { - if !util.IsMaster(&m) { - if err := d.delete(m.Name); err != nil { - return err - } - glog.Infof("Deleted machine object %s", m.Name) - } - } - return nil -} - -func (d *deployer) delete(name string) error { - err := d.client.Machines(apiv1.NamespaceDefault).Delete(name, &metav1.DeleteOptions{}) - if err != nil { - return err - } - err = util.Poll(500*time.Millisecond, 120*time.Second, func() (bool, error) { - if _, err = d.client.Machines(apiv1.NamespaceDefault).Get(name, metav1.GetOptions{}); err == nil { - return false, nil - } - return true, nil - }) - return err -} - -func (d *deployer) listMachines() ([]*clusterv1.Machine, error) { - machines, err := d.client.Machines(apiv1.NamespaceDefault).List(metav1.ListOptions{}) - if err != nil { - return nil, err - } - return util.MachineP(machines.Items), nil -} - -func (d *deployer) getCluster() (*clusterv1.Cluster, error) { - clusters, err := d.client.Clusters(apiv1.NamespaceDefault).List(metav1.ListOptions{}) - if err != nil { - return nil, err - } - if len(clusters.Items) != 1 { - return nil, fmt.Errorf("cluster object count != 1") - } - return &clusters.Items[0], nil -} - -func (d *deployer) getMasterIP(master *clusterv1.Machine) (string, error) { - for i := 0; i < MasterIPAttempts; i++ { - ip, err := d.machineDeployer.GetIP(master) - if err != nil || ip == "" { - glog.Info("Hanging for master IP...") - time.Sleep(time.Duration(SleepSecondsPerAttempt) * time.Second) - continue - } - return ip, nil - } - return "", fmt.Errorf("unable to find Master IP after defined wait") -} - -func (d *deployer) copyKubeConfig(master *clusterv1.Machine) error { - writeErr := util.Retry(func() (bool, error) { - glog.Infof("Waiting for Kubernetes to come up...") - config, err := d.machineDeployer.GetKubeConfig(master) - if err != nil { - glog.Errorf("Error while retriving kubeconfig %s", err) - return false, err - } - if config == "" { - return false, nil - } - glog.Infof("Kubernetes is up.. Writing kubeconfig to disk.") - err = d.writeConfigToDisk(config) - return (err == nil), nil - }, 5) - - if writeErr != nil { - return fmt.Errorf("timedout writing kubeconfig: %s", writeErr) - } - return nil -} - -func (d *deployer) initApiClient() error { - c, err := util.NewClientSet(d.configPath) - if err != nil { - return err - } - kubernetesClientSet, err := util.NewKubernetesClient(d.configPath) - if err != nil { - return err - } - d.clientSet = c - d.client = c.ClusterV1alpha1() - d.kubernetesClientSet = *kubernetesClientSet - return nil - -} -func (d *deployer) writeConfigToDisk(config string) error { - file, err := os.Create(d.configPath) - if err != nil { - return err - } - if _, err := file.WriteString(config); err != nil { - return err - } - defer file.Close() - - file.Sync() // flush - glog.Infof("wrote kubeconfig to [%s]", d.configPath) - return nil -} - -// Make sure you successfully call setMasterIp first. -func (d *deployer) waitForApiserver(master string) error { - endpoint := fmt.Sprintf("https://%s/healthz", master) - - // Skip certificate validation since we're only looking for signs of - // health, and we're not going to have the CA in our default chain. - tr := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, - } - client := &http.Client{Transport: tr} - - waitErr := util.Retry(func() (bool, error) { - glog.Info("Waiting for apiserver to become healthy...") - resp, err := client.Get(endpoint) - return (err == nil && resp.StatusCode == 200), nil - }, 3) - - if waitErr != nil { - glog.Errorf("Error waiting for apiserver: %s", waitErr) - return waitErr - } - return nil -} - -// Make sure the default service account in kube-system namespace exists. -func (d *deployer) waitForServiceAccount() error { - waitErr := util.Retry(func() (bool, error) { - glog.Info("Waiting for the service account to exist...") - _, err := d.kubernetesClientSet.CoreV1().ServiceAccounts(ServiceAccountNs).Get(ServiceAccountName, metav1.GetOptions{}) - return (err == nil), nil - }, 5) - - if waitErr != nil { - glog.Errorf("Error waiting for service account: %s", waitErr) - return waitErr - } - return nil -} diff --git a/tf-deployer/deploy/machinedeployer.go b/tf-deployer/deploy/machinedeployer.go deleted file mode 100644 index 7ec914ecb5ad..000000000000 --- a/tf-deployer/deploy/machinedeployer.go +++ /dev/null @@ -1,23 +0,0 @@ -package deploy - -import ( - "k8s.io/client-go/kubernetes" - clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" - "sigs.k8s.io/cluster-api/pkg/controller/machine" -) - -// Provider-specific machine logic the deployer needs. -type machineDeployer interface { - machine.Actuator - GetIP(machine *clusterv1.Machine) (string, error) - SetupRemoteMaster(machine *clusterv1.Machine) error - GetKubeConfig(master *clusterv1.Machine) (string, error) - - // Create and start the machine controller. The list of initial - // machines don't have to be reconciled as part of this function, but - // are provided in case the function wants to refer to them (and their - // ProviderConfigs) to know how to configure the machine controller. - // Not idempotent. - CreateMachineController(cluster *clusterv1.Cluster, initialMachines []*clusterv1.Machine, clientSet kubernetes.Clientset) error - PostDelete(cluster *clusterv1.Cluster, machines []*clusterv1.Machine) error -} diff --git a/tf-deployer/machines.yaml.template b/tf-deployer/machines.yaml.template deleted file mode 100644 index f013cff45fd4..000000000000 --- a/tf-deployer/machines.yaml.template +++ /dev/null @@ -1,65 +0,0 @@ -items: -- apiVersion: "cluster.k8s.io/v1alpha1" - kind: Machine - metadata: - generateName: tf-master- - labels: - set: master - spec: - providerConfig: - value: - apiVersion: "terraformproviderconfig/v1alpha1" - kind: "TerraformProviderConfig" - terraformMachine: "standard-master" - terraformVariables: [ - "user = \"\"", - "password = \"\"", - "vsphere_server = \"", - "datacenter = \"\"", - "datastore = \"\"", - "resource_pool = \"\"", - "network = \"\"", - "num_cpus = \"2\"", - "memory = \"2048\"", - "vm_template = \"\"", - "disk_label = \"\"", - "disk_size = \"\"", - "virtual_machine_domain = \"\"", - ] - versions: - kubelet: 1.10.1 - controlPlane: 1.10.1 - roles: - - Master -- apiVersion: "cluster.k8s.io/v1alpha1" - kind: Machine - metadata: - generateName: tf-node- - labels: - set: master - spec: - providerConfig: - value: - apiVersion: "terraformproviderconfig/v1alpha1" - kind: "TerraformProviderConfig" - terraformMachine: "standard-node" - terraformVariables: [ - "user = \"\"", - "password = \"\"", - "vsphere_server = \"", - "datacenter = \"\"", - "datastore = \"\"", - "resource_pool = \"\"", - "network = \"\"", - "num_cpus = \"2\"", - "memory = \"2048\"", - "vm_template = \"\"", - "disk_label = \"\"", - "disk_size = \"\"", - "virtual_machine_domain = \"\"", - ] - versions: - kubelet: 1.10.1 - controlPlane: 1.10.1 - roles: - - Node diff --git a/tf-deployer/main.go b/tf-deployer/main.go deleted file mode 100644 index c99822d32021..000000000000 --- a/tf-deployer/main.go +++ /dev/null @@ -1,23 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import "sigs.k8s.io/cluster-api/tf-deployer/cmd" - -func main() { - cmd.Execute() -} diff --git a/tf-deployer/vsphere_named_machines.yaml b/tf-deployer/vsphere_named_machines.yaml deleted file mode 100644 index a79afcc5b182..000000000000 --- a/tf-deployer/vsphere_named_machines.yaml +++ /dev/null @@ -1,288 +0,0 @@ -items: -- machineName: standard-master - machineHcl: | - variable "user" {} - variable "password" {} - variable "vsphere_server" {} - - variable "datacenter" {} - variable "datastore" {} - variable "resource_pool" {} - variable "num_cpus" {} - variable "memory" {} - variable "vm_template" {} - variable "network" { default = "VM Network"} - variable "disk_label" { default = "disk0" } - variable "disk_size" { default = 10} - - variable "vm_name" { - type = "string" - } - - provider "vsphere" { - version = "~> 1.4" - user = "${var.user}" - password = "${var.password}" - vsphere_server = "${var.vsphere_server}" - - # if you have a self-signed cert - allow_unverified_ssl = true - } - - data "vsphere_datacenter" "dc" { - name = "${var.datacenter}" - } - - data "vsphere_datastore" "datastore" { - name = "${var.datastore}" - datacenter_id = "${data.vsphere_datacenter.dc.id}" - } - - data "vsphere_resource_pool" "pool" { - name = "${var.resource_pool}" - datacenter_id = "${data.vsphere_datacenter.dc.id}" - } - - data "vsphere_network" "network" { - name = "${var.network}" - datacenter_id = "${data.vsphere_datacenter.dc.id}" - } - - data "vsphere_virtual_machine" "template" { - name = "${var.vm_template}" - datacenter_id = "${data.vsphere_datacenter.dc.id}" - } - - data "template_file" "cloud_provider_config" { - template = < - ``` - -### Set GCP Credentials - -In order to develop the vSphere machine controller, you need to configure the credentials to push a newer version of the controller to GCR. - -You can set it in two ways, as explained below. - -#### Environment Variable GOOGLE_APPLICATION_CREDENTIALS - -Steps to follow: -1. Verify that the environment variable `GOOGLE_APPLICATION_CREDENTIALS` is set pointing to valid service account credentials -2. If not set, follow the [instructions on Google Cloud Platform site](https://cloud.google.com/docs/authentication/getting-started) to have it set up. - -#### Login Using Cloud SDK - -The alternative is to set the client credentials via gcloud by executing the command line below. - -```bash -$ gcloud auth application-default login -``` - -### Install Docker - -1. Install [Docker](https://docs.docker.com/install/) on your machine; -2. Make sure your user can execute docker commmands (without sudo). This is a way to test it: -```bash -$ docker run hello-world - -Hello from Docker! -This message shows that your installation appears to be working correctly. -... -``` - -3. Run `gcloud beta auth configure-docker` to configure your credentials. - -### Install OpenSSL - -Install [OpenSSL](https://www.openssl.org/source/) on your machine. Please note that this is just temporary. We are working to remove this dependency. See [Issue](https://github.com/kubernetes/kube-deploy/issues/591) - -## Fetch Source Code - -1. Fork [cluster-api repo](https://github.com/kubernetes-sigs/cluster-api). If it's your first time forking, please take a look at [GitHub Repo instructions](https://help.github.com/articles/fork-a-repo/). The general [Kubernetes GitHub workflow](https://github.com/kubernetes/community/blob/master/contributors/guide/github-workflow.md) is helpful here too if you're getting started. - -2. Clone Repo Locally -```bash -$ cd $GOPATH/src/sigs.k8s.io/ -$ git clone https://github.com//cluster-api.git -``` - -## Build - -```bash -$ cd $GOPATH/src/sigs.k8s.io/cluster-api/vsphere-deployer/ -$ go build -``` - -This will create a binary `vsphere-deployer` in the same directory. You can use that binary to manage a cluster. - -## Developing - -When making changes to the machine controller, it's generally a good idea to delete any existing cluster created with an older version of the cluster-api. - -Note: the below command is not yet implemented. - -```bash -$ ./vsphere-deployer delete -``` - -After making changes to the controllers or the actuator, you need to follow these two steps: - -1. Rebuild the machine-controller image. Also change `machineControllerImage` in `cloud/terraform/pods.go` to the new image path (make sure the version in the Makefile and `pods.go` match if you want to use the new image). Then, rebuild and push the image. - - ```bash - $ cd $GOPATH/src/sigs.k8s.io/cluster-api/cloud/vsphere/cmd/vsphere-machine-controller - $ make dev_push - ``` - -NOTE: that the image will be pushed to `gcr.io/$GCP_PROJECT/vsphere-machine-controller`. Image storage is a billable resource. - -2. Rebuild vsphere-deployer - - ```bash - $ cd $GOPATH/src/sigs.k8s.io/cluster-api/vsphere-deployer/ - $ go build - ``` - -The new `vsphere-deployer` will have your changes. - -## Testing - -We do not have unit tests or integration tests currently. For any changes, it is recommended that you test a create-edit-delete sequence using the new machine controller image and the new `vsphere-deployer` binary. - -1. Generate machines configuration file. - -1. Create a cluster - - ```bash - $ ./vsphere-deployer create -c cluster.yaml -m machines.yaml -n vsphere_named_machines.yaml - ``` - -[Optional]To verify API server has been deployed successfully, you can the following command to double check. - - ```bash - $ kubectl get apiservices v1alpha1.cluster.k8s.io -o yaml - ``` - -2. Edit the machine to trigger an update - - ```bash - $ kubectl edit machine $MACHINE_NAME - ``` - -3. Make sure the new behavior is working as intended. Then delete the cluster. - - ```bash - $ ./vsphere-deployer delete - ``` diff --git a/vsphere-deployer/README.md b/vsphere-deployer/README.md deleted file mode 100644 index 7a771b9df13d..000000000000 --- a/vsphere-deployer/README.md +++ /dev/null @@ -1,82 +0,0 @@ -# Cluster API vSphere Deployer - -The Cluster API vSphere prototype implements the [Cluster API](https://github.com/kubernetes-sigs/cluster-api/blob/master/README.md) for vSphere 6.5. - -## Getting Started - -### Prerequisites - -Follow the steps listed at [CONTRIBUTING.md](https://github.com/kubernetes-sigs/cluster-api/blob/master/vsphere-deployer/CONTRIBUTING.md) to: - -1. Build the `vsphere-deployer` tool - ``` - cd $GOPATH/src/sigs.k8s.io/cluster-api/vsphere-deployer/ - go build - ``` -1. Create a vSphere template following [this guide](https://blog.inkubate.io/deploy-a-vmware-vsphere-virtual-machine-with-terraform/) up to **Create the vSphere Ubuntu 16.04 template** section. -1. Create a resource pool for your cluster. -1. Create a pair of ssh keys that will be used to connect to the VMs. Put your - keys in `~/.ssh/vsphere_tmp` and `~/.ssh/vsphere_tmp.pub`. - ``` - ssh-keygen -b 2048 -t rsa -f ~/.ssh/vsphere_tmp -q -N "" - ``` -1. Create a `machines.yaml` file configured for your cluster. See the provided template - for an example, if you use it, make sure to fill in all missing `terraformVariables` - in `providerConfig`. You'll also need to create a `cluster.yaml` (look at the provided `cluster.yaml.template`). - -### Limitation - -See [here](https://github.com/karan/kube-deploy/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+vsphere). - -### Creating a cluster - -1. Create a cluster: - ``` - ./vsphere-deployer create -c cluster.yaml -m machines.yaml -n vsphere_named_machines.yaml - ``` - -During cluster creation, you can watch the machine resources get created in Kubernetes, -see the corresponding virtual machines created in your provider, and then finally see nodes -join the cluster: - -```bash -$ watch -n 5 "kubectl get machines" -$ watch -n 5 "kubectl get nodes" -``` - - -### Interacting with your cluster - -Once you have created a cluster, you can interact with the cluster and machine -resources using kubectl: - -``` -$ kubectl get clusters -$ kubectl get machines -$ kubectl get machines -o yaml -``` - -#### Scaling your cluster - -**NOT YET SUPPORTED!** - -#### Upgrading your cluster - -**NOT YET SUPPORTED!** - -#### Node repair - -**NOT YET SUPPORTED!** - -### Deleting a cluster - -**NOT YET SUPPORTED!** - -### How does the prototype work? - -Right now, the Cluster and Machine objects are stored as resources in an extension apiserver, which -connected with main apiserver through api aggregation. We deploy the extension API server and -controller manager as a pod inside the cluster. Like other resources in Kubernetes, machine -controller as part of controller manager is responsible to reconcile the actual vs. desired machine -state. Bootstrapping and in-place upgrading is handled by -[kubeadm](https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/). diff --git a/vsphere-deployer/cluster.yaml.template b/vsphere-deployer/cluster.yaml.template deleted file mode 100644 index ec613c2baddb..000000000000 --- a/vsphere-deployer/cluster.yaml.template +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: "cluster.k8s.io/v1alpha1" -kind: Cluster -metadata: - name: test1 -spec: - clusterNetwork: - services: - cidrBlocks: ["10.96.0.0/12"] - pods: - cidrBlocks: ["192.168.0.0/16"] - serviceDomain: "cluster.local" - providerConfig: - value: - apiVersion: "vsphereproviderconfig/v1alpha1" - kind: "VsphereClusterProviderConfig" - vsphereUser: "" - vspherePassword: "" - vsphereServer: "" \ No newline at end of file diff --git a/vsphere-deployer/cmd/add.go b/vsphere-deployer/cmd/add.go deleted file mode 100644 index 08e8cc44d4b1..000000000000 --- a/vsphere-deployer/cmd/add.go +++ /dev/null @@ -1,63 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cmd - -import ( - "os" - - "github.com/golang/glog" - "github.com/spf13/cobra" - "sigs.k8s.io/cluster-api/vsphere-deployer/deploy" -) - -type AddOptions struct { - Machine string -} - -var ao = &AddOptions{} - -var addCmd = &cobra.Command{ - Use: "add", - Short: "Add nodes to cluster", - Long: `Add nodes to cluster`, - Run: func(cmd *cobra.Command, args []string) { - if ao.Machine == "" { - glog.Error("Please provide yaml file for machine definition.") - cmd.Help() - os.Exit(1) - } - if err := RunAdd(ao); err != nil { - glog.Exit(err) - } - }, -} - -func RunAdd(ao *AddOptions) error { - machines, err := parseMachinesYaml(ao.Machine) - if err != nil { - return err - } - - d := deploy.NewDeployer(kubeConfig, "") - - return d.AddNodes(machines) -} -func init() { - addCmd.Flags().StringVarP(&ao.Machine, "machines", "m", "", "machine yaml file") - - RootCmd.AddCommand(addCmd) -} diff --git a/vsphere-deployer/cmd/create.go b/vsphere-deployer/cmd/create.go deleted file mode 100644 index 5e74c04fca6b..000000000000 --- a/vsphere-deployer/cmd/create.go +++ /dev/null @@ -1,83 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cmd - -import ( - "os" - - "fmt" - "github.com/golang/glog" - "github.com/spf13/cobra" - "sigs.k8s.io/cluster-api/vsphere-deployer/deploy" -) - -type CreateOptions struct { - Cluster string - Machine string - NamedMachinePath string -} - -var co = &CreateOptions{} - -var createCmd = &cobra.Command{ - Use: "create", - Short: "Create kubernetes cluster", - Long: `Create a kubernetes cluster with one command`, - Run: func(cmd *cobra.Command, args []string) { - if co.Cluster == "" { - glog.Error("Please provide yaml file for cluster definition.") - cmd.Help() - os.Exit(1) - } - if co.Machine == "" { - glog.Error("Please provide yaml file for machine definition.") - cmd.Help() - os.Exit(1) - } - if co.NamedMachinePath == "" { - glog.Error("Please provide a yaml file for machine HCL configs.") - cmd.Help() - os.Exit(1) - } - if err := RunCreate(co); err != nil { - glog.Exit(err) - } - }, -} - -func RunCreate(co *CreateOptions) error { - cluster, err := parseClusterYaml(co.Cluster) - if err != nil { - return fmt.Errorf("Error parsing cluster yaml: %+v", err) - } - - machines, err := parseMachinesYaml(co.Machine) - if err != nil { - return fmt.Errorf("Error parsing machines yaml: %+v", err) - } - - d := deploy.NewDeployer(kubeConfig, co.NamedMachinePath) - - return d.CreateCluster(cluster, machines) -} -func init() { - createCmd.Flags().StringVarP(&co.Cluster, "cluster", "c", "", "cluster yaml file") - createCmd.Flags().StringVarP(&co.Machine, "machines", "m", "", "machine yaml file") - createCmd.Flags().StringVarP(&co.NamedMachinePath, "namedmachines", "n", "", "named machines yaml file") - - RootCmd.AddCommand(createCmd) -} diff --git a/vsphere-deployer/cmd/delete.go b/vsphere-deployer/cmd/delete.go deleted file mode 100644 index 0e40b09ee426..000000000000 --- a/vsphere-deployer/cmd/delete.go +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cmd - -import ( - "github.com/golang/glog" - "github.com/spf13/cobra" - "sigs.k8s.io/cluster-api/vsphere-deployer/deploy" -) - -var deleteCmd = &cobra.Command{ - Use: "delete", - Short: "Delete kubernetes cluster", - Long: `Delete a kubernetes cluster with one command`, - Run: func(cmd *cobra.Command, args []string) { - if err := RunDelete(); err != nil { - glog.Exit(err) - } - }, -} - -func RunDelete() error { - d := deploy.NewDeployer(kubeConfig, "") - return d.DeleteCluster() -} - -func init() { - RootCmd.AddCommand(deleteCmd) -} diff --git a/vsphere-deployer/cmd/root.go b/vsphere-deployer/cmd/root.go deleted file mode 100644 index 1eddb4d69701..000000000000 --- a/vsphere-deployer/cmd/root.go +++ /dev/null @@ -1,85 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cmd - -import ( - "flag" - "io/ioutil" - - "github.com/ghodss/yaml" - "github.com/golang/glog" - "github.com/spf13/cobra" - "k8s.io/apiserver/pkg/util/logs" - clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" - "sigs.k8s.io/cluster-api/util" -) - -var RootCmd = &cobra.Command{ - Use: "vsphere-deployer", - Short: "cluster management", - Long: `Simple kubernetes cluster management`, - Run: func(cmd *cobra.Command, args []string) { - // Do Stuff Here - cmd.Help() - }, -} - -var ( - kubeConfig string -) - -func Execute() { - if err := RootCmd.Execute(); err != nil { - glog.Exit(err) - } -} - -func parseClusterYaml(file string) (*clusterv1.Cluster, error) { - bytes, err := ioutil.ReadFile(file) - if err != nil { - return nil, err - } - - cluster := &clusterv1.Cluster{} - err = yaml.Unmarshal(bytes, cluster) - if err != nil { - return nil, err - } - - return cluster, nil -} - -func parseMachinesYaml(file string) ([]*clusterv1.Machine, error) { - bytes, err := ioutil.ReadFile(file) - if err != nil { - return nil, err - } - - machines := &clusterv1.MachineList{} - err = yaml.Unmarshal(bytes, &machines) - if err != nil { - return nil, err - } - - return util.MachineP(machines.Items), nil -} - -func init() { - RootCmd.PersistentFlags().StringVarP(&kubeConfig, "kubeconfig", "k", "", "location for the kubernetes config file. If not provided, $HOME/.kube/config is used") - flag.CommandLine.Parse([]string{}) - logs.InitLogs() -} diff --git a/vsphere-deployer/deploy/deploy.go b/vsphere-deployer/deploy/deploy.go deleted file mode 100644 index a464504dc15f..000000000000 --- a/vsphere-deployer/deploy/deploy.go +++ /dev/null @@ -1,134 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package deploy - -import ( - "fmt" - "os" - - "github.com/golang/glog" - "k8s.io/client-go/kubernetes" - "sigs.k8s.io/cluster-api/cloud/vsphere" - clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" - "sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset" - "sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1" - "sigs.k8s.io/cluster-api/util" - apiutil "sigs.k8s.io/cluster-api/util" -) - -type deployer struct { - token string - configPath string - machineDeployer machineDeployer - client v1alpha1.ClusterV1alpha1Interface - clientSet clientset.Interface - kubernetesClientSet kubernetes.Clientset -} - -// NewDeployer returns a cloud provider specific deployer and -// sets kubeconfig path for the cluster to be deployed -func NewDeployer(configPath, namedMachinesPath string) *deployer { - token := util.RandomToken() - if configPath == "" { - configPath = os.Getenv("KUBECONFIG") - if configPath == "" { - configPath = apiutil.GetDefaultKubeConfigPath() - } - } else { - // This is needed for kubectl commands run later to create secret in function - // CreateMachineControllerServiceAccount - if err := os.Setenv("KUBECONFIG", configPath); err != nil { - glog.Exit(fmt.Sprintf("Failed to set Kubeconfig path err %v\n", err)) - } - } - ma, err := vsphere.NewMachineActuator(token, nil, namedMachinesPath) - if err != nil { - glog.Exit(err) - } - return &deployer{ - token: token, - machineDeployer: ma, - configPath: configPath, - } -} - -func (d *deployer) CreateCluster(c *clusterv1.Cluster, machines []*clusterv1.Machine) error { - vmCreated := false - if err := d.createCluster(c, machines, &vmCreated); err != nil { - if vmCreated { - d.deleteMasterVM(c, machines) - } - d.machineDeployer.PostDelete(c, machines) - return err - } - - glog.Infof("The [%s] cluster has been created successfully!", c.Name) - glog.Info("You can now `kubectl get nodes`") - return nil -} - -func (d *deployer) AddNodes(machines []*clusterv1.Machine) error { - if err := d.createMachines(machines); err != nil { - return err - } - return nil -} - -func (d *deployer) DeleteCluster() error { - if err := d.initApiClient(); err != nil { - return err - } - - machines, err := d.listMachines() - if err != nil { - return err - } - - cluster, err := d.getCluster() - if err != nil { - return err - } - - glog.Info("Deleting machine objects") - if err := d.deleteAllMachines(); err != nil { - return err - } - - if err := d.deleteMasterVM(cluster, machines); err != nil { - glog.Errorf("Error deleting master vm", err) - } - - glog.Info("Running post delete operations") - if err := d.machineDeployer.PostDelete(cluster, machines); err != nil { - return err - } - glog.Infof("Deletion complete") - return nil -} - -func (d *deployer) deleteMasterVM(cluster *clusterv1.Cluster, machines []*clusterv1.Machine) error { - master := util.GetMaster(machines) - if master == nil { - return fmt.Errorf("error deleting master vm, no master found") - } - - glog.Infof("Deleting master vm %s", master.Name) - if err := d.machineDeployer.Delete(cluster, master); err != nil { - return err - } - return nil -} diff --git a/vsphere-deployer/deploy/deploy_helper.go b/vsphere-deployer/deploy/deploy_helper.go deleted file mode 100644 index 59e17dac3126..000000000000 --- a/vsphere-deployer/deploy/deploy_helper.go +++ /dev/null @@ -1,300 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package deploy - -import ( - "crypto/tls" - "fmt" - "net/http" - "os" - "time" - - "github.com/golang/glog" - apiv1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" - "sigs.k8s.io/cluster-api/util" -) - -const ( - MasterIPAttempts = 40 - SleepSecondsPerAttempt = 5 - ServiceAccountNs = "kube-system" - ServiceAccountName = "default" -) - -func (d *deployer) createCluster(c *clusterv1.Cluster, machines []*clusterv1.Machine, vmCreated *bool) error { - if c.GetName() == "" { - return fmt.Errorf("cluster name must be specified for cluster creation") - } - master := util.GetMaster(machines) - if master == nil { - return fmt.Errorf("master spec must be provided for cluster creation") - } - - if master.GetName() == "" && master.GetGenerateName() == "" { - return fmt.Errorf("master name must be specified for cluster creation") - } - - if master.GetName() == "" { - master.Name = master.GetGenerateName() + c.GetName() - } - - glog.Infof("Starting cluster creation %s", c.GetName()) - - glog.Infof("Starting master creation %s", master.GetName()) - - if err := d.machineDeployer.Create(c, master); err != nil { - return err - } - - *vmCreated = true - glog.Infof("Created master %s", master.GetName()) - - masterIP, err := d.getMasterIP(master) - if err != nil { - return fmt.Errorf("unable to get master IP: %v", err) - } - - if err := d.machineDeployer.SetupRemoteMaster(master); err != nil { - return fmt.Errorf("unable to setup the master: %v", err) - } - - if err := d.copyKubeConfig(master); err != nil { - return fmt.Errorf("unable to write kubeconfig: %v", err) - } - - if err := d.waitForApiserver(masterIP); err != nil { - return fmt.Errorf("apiserver never came up: %v", err) - } - - if err := d.initApiClient(); err != nil { - return err - } - - if err := d.waitForServiceAccount(); err != nil { - return fmt.Errorf("service account %s/%s not found: %v", ServiceAccountNs, ServiceAccountName, err) - } - - glog.Info("Deploying the addon apiserver and controller manager...") - if err := d.machineDeployer.CreateMachineController(c, machines, d.kubernetesClientSet); err != nil { - return fmt.Errorf("can't create machine controller: %v", err) - } - - if err := d.waitForClusterResourceReady(); err != nil { - return err - } - - c, err = d.client.Clusters(apiv1.NamespaceDefault).Create(c) - if err != nil { - return err - } - - c.Status.APIEndpoints = append(c.Status.APIEndpoints, - clusterv1.APIEndpoint{ - Host: masterIP, - Port: 443, - }) - if _, err := d.client.Clusters(apiv1.NamespaceDefault).UpdateStatus(c); err != nil { - return err - } - - if err := d.createMachines(machines); err != nil { - return err - } - return nil -} - -func (d *deployer) waitForClusterResourceReady() error { - err := util.Poll(500*time.Millisecond, 120*time.Second, func() (bool, error) { - _, err := d.clientSet.Discovery().ServerResourcesForGroupVersion("cluster.k8s.io/v1alpha1") - if err == nil { - return true, nil - } - return false, nil - }) - - return err -} - -func (d *deployer) createMachines(machines []*clusterv1.Machine) error { - for _, machine := range machines { - m, err := d.client.Machines(apiv1.NamespaceDefault).Create(machine) - if err != nil { - return err - } - glog.Infof("Added machine [%s]", m.Name) - } - return nil -} - -func (d *deployer) createMachine(m *clusterv1.Machine) error { - return d.createMachines([]*clusterv1.Machine{m}) -} - -func (d *deployer) deleteAllMachines() error { - machines, err := d.client.Machines(apiv1.NamespaceDefault).List(metav1.ListOptions{}) - if err != nil { - return err - } - for _, m := range machines.Items { - if !util.IsMaster(&m) { - if err := d.delete(m.Name); err != nil { - return err - } - glog.Infof("Deleted machine object %s", m.Name) - } - } - return nil -} - -func (d *deployer) delete(name string) error { - err := d.client.Machines(apiv1.NamespaceDefault).Delete(name, &metav1.DeleteOptions{}) - if err != nil { - return err - } - err = util.Poll(500*time.Millisecond, 120*time.Second, func() (bool, error) { - if _, err = d.client.Machines(apiv1.NamespaceDefault).Get(name, metav1.GetOptions{}); err == nil { - return false, nil - } - return true, nil - }) - return err -} - -func (d *deployer) listMachines() ([]*clusterv1.Machine, error) { - machines, err := d.client.Machines(apiv1.NamespaceDefault).List(metav1.ListOptions{}) - if err != nil { - return nil, err - } - return util.MachineP(machines.Items), nil -} - -func (d *deployer) getCluster() (*clusterv1.Cluster, error) { - clusters, err := d.client.Clusters(apiv1.NamespaceDefault).List(metav1.ListOptions{}) - if err != nil { - return nil, err - } - if len(clusters.Items) != 1 { - return nil, fmt.Errorf("cluster object count != 1") - } - return &clusters.Items[0], nil -} - -func (d *deployer) getMasterIP(master *clusterv1.Machine) (string, error) { - for i := 0; i < MasterIPAttempts; i++ { - ip, err := d.machineDeployer.GetIP(master) - if err != nil || ip == "" { - glog.Info("Hanging for master IP...") - time.Sleep(time.Duration(SleepSecondsPerAttempt) * time.Second) - continue - } - return ip, nil - } - return "", fmt.Errorf("unable to find Master IP after defined wait") -} - -func (d *deployer) copyKubeConfig(master *clusterv1.Machine) error { - writeErr := util.Retry(func() (bool, error) { - glog.Infof("Waiting for Kubernetes to come up...") - config, err := d.machineDeployer.GetKubeConfig(master) - if err != nil { - glog.Errorf("Error while retriving kubeconfig %s", err) - return false, err - } - if config == "" { - return false, nil - } - glog.Infof("Kubernetes is up.. Writing kubeconfig to disk.") - err = d.writeConfigToDisk(config) - return (err == nil), nil - }, 5) - - if writeErr != nil { - return fmt.Errorf("timedout writing kubeconfig: %s", writeErr) - } - return nil -} - -func (d *deployer) initApiClient() error { - c, err := util.NewClientSet(d.configPath) - if err != nil { - return err - } - kubernetesClientSet, err := util.NewKubernetesClient(d.configPath) - if err != nil { - return err - } - d.clientSet = c - d.client = c.ClusterV1alpha1() - d.kubernetesClientSet = *kubernetesClientSet - return nil - -} -func (d *deployer) writeConfigToDisk(config string) error { - file, err := os.Create(d.configPath) - if err != nil { - return err - } - if _, err := file.WriteString(config); err != nil { - return err - } - defer file.Close() - - file.Sync() // flush - glog.Infof("wrote kubeconfig to [%s]", d.configPath) - return nil -} - -// Make sure you successfully call setMasterIp first. -func (d *deployer) waitForApiserver(master string) error { - endpoint := fmt.Sprintf("https://%s/healthz", master) - - // Skip certificate validation since we're only looking for signs of - // health, and we're not going to have the CA in our default chain. - tr := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, - } - client := &http.Client{Transport: tr} - - waitErr := util.Retry(func() (bool, error) { - glog.Info("Waiting for apiserver to become healthy...") - resp, err := client.Get(endpoint) - return (err == nil && resp.StatusCode == 200), nil - }, 3) - - if waitErr != nil { - glog.Errorf("Error waiting for apiserver: %s", waitErr) - return waitErr - } - return nil -} - -// Make sure the default service account in kube-system namespace exists. -func (d *deployer) waitForServiceAccount() error { - waitErr := util.Retry(func() (bool, error) { - glog.Info("Waiting for the service account to exist...") - _, err := d.kubernetesClientSet.CoreV1().ServiceAccounts(ServiceAccountNs).Get(ServiceAccountName, metav1.GetOptions{}) - return (err == nil), nil - }, 5) - - if waitErr != nil { - glog.Errorf("Error waiting for service account: %s", waitErr) - return waitErr - } - return nil -} diff --git a/vsphere-deployer/deploy/machinedeployer.go b/vsphere-deployer/deploy/machinedeployer.go deleted file mode 100644 index 7ec914ecb5ad..000000000000 --- a/vsphere-deployer/deploy/machinedeployer.go +++ /dev/null @@ -1,23 +0,0 @@ -package deploy - -import ( - "k8s.io/client-go/kubernetes" - clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" - "sigs.k8s.io/cluster-api/pkg/controller/machine" -) - -// Provider-specific machine logic the deployer needs. -type machineDeployer interface { - machine.Actuator - GetIP(machine *clusterv1.Machine) (string, error) - SetupRemoteMaster(machine *clusterv1.Machine) error - GetKubeConfig(master *clusterv1.Machine) (string, error) - - // Create and start the machine controller. The list of initial - // machines don't have to be reconciled as part of this function, but - // are provided in case the function wants to refer to them (and their - // ProviderConfigs) to know how to configure the machine controller. - // Not idempotent. - CreateMachineController(cluster *clusterv1.Cluster, initialMachines []*clusterv1.Machine, clientSet kubernetes.Clientset) error - PostDelete(cluster *clusterv1.Cluster, machines []*clusterv1.Machine) error -} diff --git a/vsphere-deployer/machines.yaml.template b/vsphere-deployer/machines.yaml.template deleted file mode 100644 index fdc67b732bef..000000000000 --- a/vsphere-deployer/machines.yaml.template +++ /dev/null @@ -1,59 +0,0 @@ -items: -- apiVersion: "cluster.k8s.io/v1alpha1" - kind: Machine - metadata: - generateName: tf-master- - labels: - set: master - spec: - providerConfig: - value: - apiVersion: "vsphereproviderconfig/v1alpha1" - kind: "VsphereMachineProviderConfig" - vsphereMachine: "standard-master" - terraformVariables: [ - "datacenter = \"\"", - "datastore = \"\"", - "resource_pool = \"\"", - "network = \"\"", - "num_cpus = \"2\"", - "memory = \"2048\"", - "vm_template = \"\"", - "disk_label = \"\"", - "disk_size = \"\"", - "virtual_machine_domain = \"\"", - ] - versions: - kubelet: 1.10.1 - controlPlane: 1.10.1 - roles: - - Master -- apiVersion: "cluster.k8s.io/v1alpha1" - kind: Machine - metadata: - generateName: tf-node- - labels: - set: master - spec: - providerConfig: - value: - apiVersion: "vsphereproviderconfig/v1alpha1" - kind: "VsphereMachineProviderConfig" - vsphereMachine: "standard-node" - terraformVariables: [ - "datacenter = \"\"", - "datastore = \"\"", - "resource_pool = \"\"", - "network = \"\"", - "num_cpus = \"2\"", - "memory = \"2048\"", - "vm_template = \"\"", - "disk_label = \"\"", - "disk_size = \"\"", - "virtual_machine_domain = \"\"", - ] - versions: - kubelet: 1.10.1 - controlPlane: 1.10.1 - roles: - - Node diff --git a/vsphere-deployer/main.go b/vsphere-deployer/main.go deleted file mode 100644 index eed8589322c5..000000000000 --- a/vsphere-deployer/main.go +++ /dev/null @@ -1,23 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import "sigs.k8s.io/cluster-api/vsphere-deployer/cmd" - -func main() { - cmd.Execute() -} diff --git a/vsphere-deployer/vsphere_named_machines.yaml b/vsphere-deployer/vsphere_named_machines.yaml deleted file mode 100644 index 56258b1c00aa..000000000000 --- a/vsphere-deployer/vsphere_named_machines.yaml +++ /dev/null @@ -1,296 +0,0 @@ -items: -- machineName: standard-master - machineHcl: | - variable "vsphere_user" {} - variable "vsphere_password" {} - variable "vsphere_server" {} - - variable "datacenter" {} - variable "datastore" {} - variable "resource_pool" {} - variable "num_cpus" {} - variable "memory" {} - variable "vm_template" {} - variable "network" { default = "VM Network"} - variable "disk_label" { default = "disk0" } - variable "disk_size" { default = 10} - - variable "vm_name" { - type = "string" - } - - provider "vsphere" { - version = "~> 1.5.0" - user = "${var.vsphere_user}" - password = "${var.vsphere_password}" - vsphere_server = "${var.vsphere_server}" - - # if you have a self-signed cert - allow_unverified_ssl = true - } - - provider "template" { - version = "~> 1.0.0" - } - - data "vsphere_datacenter" "dc" { - name = "${var.datacenter}" - } - - data "vsphere_datastore" "datastore" { - name = "${var.datastore}" - datacenter_id = "${data.vsphere_datacenter.dc.id}" - } - - data "vsphere_resource_pool" "pool" { - name = "${var.resource_pool}" - datacenter_id = "${data.vsphere_datacenter.dc.id}" - } - - data "vsphere_network" "network" { - name = "${var.network}" - datacenter_id = "${data.vsphere_datacenter.dc.id}" - } - - data "vsphere_virtual_machine" "template" { - name = "${var.vm_template}" - datacenter_id = "${data.vsphere_datacenter.dc.id}" - } - - data "template_file" "cloud_provider_config" { - template = <