diff --git a/cmd/kops/create.go b/cmd/kops/create.go index 73d5b9e58f73d..d902c4f54164c 100644 --- a/cmd/kops/create.go +++ b/cmd/kops/create.go @@ -99,7 +99,7 @@ func RunCreate(f *util.Factory, cmd *cobra.Command, out io.Writer, c *CreateOpti _, err = clientset.Federations().Create(v) if err != nil { if errors.IsAlreadyExists(err) { - return fmt.Errorf("federation %q already exists", v.Name) + return fmt.Errorf("federation %q already exists", v.ObjectMeta.Name) } return fmt.Errorf("error creating federation: %v", err) } @@ -108,20 +108,20 @@ func RunCreate(f *util.Factory, cmd *cobra.Command, out io.Writer, c *CreateOpti _, err = clientset.Clusters().Create(v) if err != nil { if errors.IsAlreadyExists(err) { - return fmt.Errorf("cluster %q already exists", v.Name) + return fmt.Errorf("cluster %q already exists", v.ObjectMeta.Name) } return fmt.Errorf("error creating cluster: %v", err) } case *kopsapi.InstanceGroup: - clusterName := v.Labels[ClusterNameLabel] + clusterName := v.ObjectMeta.Labels[ClusterNameLabel] if clusterName == "" { return fmt.Errorf("must specify %q label with cluster name to create instanceGroup", ClusterNameLabel) } _, err = clientset.InstanceGroups(clusterName).Create(v) if err != nil { if errors.IsAlreadyExists(err) { - return fmt.Errorf("instanceGroup %q already exists", v.Name) + return fmt.Errorf("instanceGroup %q already exists", v.ObjectMeta.Name) } return fmt.Errorf("error creating instanceGroup: %v", err) } diff --git a/cmd/kops/create_cluster.go b/cmd/kops/create_cluster.go index c8a62fb7e6434..658f90f0dc20c 100644 --- a/cmd/kops/create_cluster.go +++ b/cmd/kops/create_cluster.go @@ -246,7 +246,7 @@ func RunCreateCluster(f *util.Factory, cmd *cobra.Command, args []string, out io g.Spec.Zones = []string{zone.Name} g.Spec.MinSize = fi.Int(1) g.Spec.MaxSize = fi.Int(1) - g.Name = "master-" + zone.Name // Subsequent masters (if we support that) could be -1, -2 + g.ObjectMeta.Name = "master-" + zone.Name // Subsequent masters (if we support that) could be -1, -2 instanceGroups = append(instanceGroups, g) masters = append(masters, g) @@ -263,7 +263,7 @@ func RunCreateCluster(f *util.Factory, cmd *cobra.Command, args []string, out io g.Spec.Zones = []string{zone} g.Spec.MinSize = fi.Int(1) g.Spec.MaxSize = fi.Int(1) - g.Name = "master-" + zone + g.ObjectMeta.Name = "master-" + zone instanceGroups = append(instanceGroups, g) masters = append(masters, g) } @@ -298,7 +298,7 @@ func RunCreateCluster(f *util.Factory, cmd *cobra.Command, args []string, out io if len(nodes) == 0 { g := &api.InstanceGroup{} g.Spec.Role = api.InstanceGroupRoleNode - g.Name = "nodes" + g.ObjectMeta.Name = "nodes" instanceGroups = append(instanceGroups, g) nodes = append(nodes, g) } @@ -345,7 +345,7 @@ func RunCreateCluster(f *util.Factory, cmd *cobra.Command, args []string, out io } if clusterName != "" { - cluster.Name = clusterName + cluster.ObjectMeta.Name = clusterName } if c.KubernetesVersion != "" { @@ -522,10 +522,10 @@ func RunCreateCluster(f *util.Factory, cmd *cobra.Command, args []string, out io fmt.Fprintf(&sb, " * list clusters with: kops get cluster\n") fmt.Fprintf(&sb, " * edit this cluster with: kops edit cluster %s\n", clusterName) if len(nodes) > 0 { - fmt.Fprintf(&sb, " * edit your node instance group: kops edit ig --name=%s %s\n", clusterName, nodes[0].Name) + fmt.Fprintf(&sb, " * edit your node instance group: kops edit ig --name=%s %s\n", clusterName, nodes[0].ObjectMeta.Name) } if len(masters) > 0 { - fmt.Fprintf(&sb, " * edit your master instance group: kops edit ig --name=%s %s\n", clusterName, masters[0].Name) + fmt.Fprintf(&sb, " * edit your master instance group: kops edit ig --name=%s %s\n", clusterName, masters[0].ObjectMeta.Name) } fmt.Fprintf(&sb, "\n") fmt.Fprintf(&sb, "Finally configure your cluster with: kops update cluster %s --yes\n", clusterName) @@ -539,7 +539,7 @@ func RunCreateCluster(f *util.Factory, cmd *cobra.Command, args []string, out io glog.Infof("Exporting kubecfg for cluster") x := &kutil.CreateKubecfg{ - ContextName: cluster.Name, + ContextName: cluster.ObjectMeta.Name, KeyStore: keyStore, SecretStore: secretStore, KubeMasterIP: cluster.Spec.MasterPublicName, diff --git a/cmd/kops/create_ig.go b/cmd/kops/create_ig.go index e90ca298693cc..1c3ebde9585bd 100644 --- a/cmd/kops/create_ig.go +++ b/cmd/kops/create_ig.go @@ -72,7 +72,7 @@ func RunCreateInstanceGroup(f *util.Factory, cmd *cobra.Command, args []string, return err } - existing, err := clientset.InstanceGroups(cluster.Name).Get(groupName) + existing, err := clientset.InstanceGroups(cluster.ObjectMeta.Name).Get(groupName) if err != nil { return err } @@ -83,7 +83,7 @@ func RunCreateInstanceGroup(f *util.Factory, cmd *cobra.Command, args []string, // Populate some defaults ig := &api.InstanceGroup{} - ig.Name = groupName + ig.ObjectMeta.Name = groupName ig.Spec.Role = api.InstanceGroupRoleNode ig, err = cloudup.PopulateInstanceGroupSpec(cluster, ig, channel) @@ -123,7 +123,7 @@ func RunCreateInstanceGroup(f *util.Factory, cmd *cobra.Command, args []string, return err } - _, err = clientset.InstanceGroups(cluster.Name).Create(group) + _, err = clientset.InstanceGroups(cluster.ObjectMeta.Name).Create(group) if err != nil { return fmt.Errorf("error storing InstanceGroup: %v", err) } diff --git a/cmd/kops/delete_cluster.go b/cmd/kops/delete_cluster.go index 4055cd494a538..6d678ef43ff8b 100644 --- a/cmd/kops/delete_cluster.go +++ b/cmd/kops/delete_cluster.go @@ -107,7 +107,7 @@ func (c *DeleteClusterCmd) Run(args []string) error { return fmt.Errorf("cluster %q not found", clusterName) } - if clusterName != cluster.Name { + if clusterName != cluster.ObjectMeta.Name { return fmt.Errorf("sanity check failed: cluster name mismatch") } diff --git a/cmd/kops/delete_instancegroup.go b/cmd/kops/delete_instancegroup.go index 1438da1373d60..1e842bfcd950c 100644 --- a/cmd/kops/delete_instancegroup.go +++ b/cmd/kops/delete_instancegroup.go @@ -67,7 +67,7 @@ func (c *DeleteInstanceceGroupCmd) Run(groupName string) error { return err } - group, err := clientset.InstanceGroups(cluster.Name).Get(groupName) + group, err := clientset.InstanceGroups(cluster.ObjectMeta.Name).Get(groupName) if err != nil { return fmt.Errorf("error reading InstanceGroup %q: %v", groupName, err) } @@ -90,7 +90,7 @@ func (c *DeleteInstanceceGroupCmd) Run(groupName string) error { return err } - fmt.Printf("InstanceGroup %q deleted\n", group.Name) + fmt.Printf("InstanceGroup %q deleted\n", group.ObjectMeta.Name) return nil } diff --git a/cmd/kops/edit_cluster.go b/cmd/kops/edit_cluster.go index 5df5cb2550aeb..1ff5c188be09d 100644 --- a/cmd/kops/edit_cluster.go +++ b/cmd/kops/edit_cluster.go @@ -74,7 +74,7 @@ func RunEditCluster(f *util.Factory, cmd *cobra.Command, args []string, out io.W return err } - list, err := clientset.InstanceGroups(oldCluster.Name).List(k8sapi.ListOptions{}) + list, err := clientset.InstanceGroups(oldCluster.ObjectMeta.Name).List(k8sapi.ListOptions{}) if err != nil { return err } diff --git a/cmd/kops/edit_instancegroup.go b/cmd/kops/edit_instancegroup.go index 8a3c1bc87f0e0..3b9a78617338c 100644 --- a/cmd/kops/edit_instancegroup.go +++ b/cmd/kops/edit_instancegroup.go @@ -82,7 +82,7 @@ func RunEditInstanceGroup(f *util.Factory, cmd *cobra.Command, args []string, ou return fmt.Errorf("name is required") } - oldGroup, err := clientset.InstanceGroups(cluster.Name).Get(groupName) + oldGroup, err := clientset.InstanceGroups(cluster.ObjectMeta.Name).Get(groupName) if err != nil { return fmt.Errorf("error reading InstanceGroup %q: %v", groupName, err) } @@ -150,7 +150,7 @@ func RunEditInstanceGroup(f *util.Factory, cmd *cobra.Command, args []string, ou } // Note we perform as much validation as we can, before writing a bad config - _, err = clientset.InstanceGroups(cluster.Name).Update(fullGroup) + _, err = clientset.InstanceGroups(cluster.ObjectMeta.Name).Update(fullGroup) if err != nil { return err } diff --git a/cmd/kops/export_kubecfg.go b/cmd/kops/export_kubecfg.go index 1560779af943f..071a6bf4bdbcb 100644 --- a/cmd/kops/export_kubecfg.go +++ b/cmd/kops/export_kubecfg.go @@ -67,7 +67,7 @@ func (c *ExportKubecfgCommand) Run(args []string) error { return err } - clusterName := cluster.Name + clusterName := cluster.ObjectMeta.Name master := cluster.Spec.MasterPublicName if master == "" { diff --git a/cmd/kops/get_cluster.go b/cmd/kops/get_cluster.go index 9efda49df92e0..06b82aabf84d3 100644 --- a/cmd/kops/get_cluster.go +++ b/cmd/kops/get_cluster.go @@ -68,7 +68,7 @@ func (c *GetClustersCmd) Run(args []string) error { m := make(map[string]*api.Cluster) for i := range clusterList.Items { c := &clusterList.Items[i] - m[c.Name] = c + m[c.ObjectMeta.Name] = c } for _, arg := range args { ig := m[arg] @@ -94,7 +94,7 @@ func (c *GetClustersCmd) Run(args []string) error { if output == OutputTable { t := &tables.Table{} t.AddColumn("NAME", func(c *api.Cluster) string { - return c.Name + return c.ObjectMeta.Name }) t.AddColumn("CLOUD", func(c *api.Cluster) string { return c.Spec.CloudProvider @@ -113,12 +113,12 @@ func (c *GetClustersCmd) Run(args []string) error { for _, cluster := range clusters { configBase, err := registry.ConfigBase(cluster) if err != nil { - return fmt.Errorf("error reading full cluster spec for %q: %v", cluster.Name, err) + return fmt.Errorf("error reading full cluster spec for %q: %v", cluster.ObjectMeta.Name, err) } fullSpec := &api.Cluster{} err = registry.ReadConfigDeprecated(configBase.Join(registry.PathClusterCompleted), fullSpec) if err != nil { - return fmt.Errorf("error reading full cluster spec for %q: %v", cluster.Name, err) + return fmt.Errorf("error reading full cluster spec for %q: %v", cluster.ObjectMeta.Name, err) } fullSpecs = append(fullSpecs, fullSpec) } @@ -128,7 +128,7 @@ func (c *GetClustersCmd) Run(args []string) error { for _, cluster := range clusters { y, err := api.ToYaml(cluster) if err != nil { - return fmt.Errorf("error marshaling yaml for %q: %v", cluster.Name, err) + return fmt.Errorf("error marshaling yaml for %q: %v", cluster.ObjectMeta.Name, err) } _, err = os.Stdout.Write(y) if err != nil { diff --git a/cmd/kops/get_federation.go b/cmd/kops/get_federation.go index 876d03d0d54b8..c5a3b97e40fc6 100644 --- a/cmd/kops/get_federation.go +++ b/cmd/kops/get_federation.go @@ -73,7 +73,7 @@ func RunGetFederations(context Factory, out io.Writer, options *GetFederationOpt if output == OutputTable { t := &tables.Table{} t.AddColumn("NAME", func(f *api.Federation) string { - return f.Name + return f.ObjectMeta.Name }) t.AddColumn("CONTROLLERS", func(f *api.Federation) string { return strings.Join(f.Spec.Controllers, ",") @@ -86,7 +86,7 @@ func RunGetFederations(context Factory, out io.Writer, options *GetFederationOpt for _, f := range federations { y, err := api.ToYaml(f) if err != nil { - return fmt.Errorf("error marshaling yaml for %q: %v", f.Name, err) + return fmt.Errorf("error marshaling yaml for %q: %v", f.ObjectMeta.Name, err) } _, err = out.Write(y) if err != nil { diff --git a/cmd/kops/get_instancegroups.go b/cmd/kops/get_instancegroups.go index 98df80df3af7b..2ca80090e58cc 100644 --- a/cmd/kops/get_instancegroups.go +++ b/cmd/kops/get_instancegroups.go @@ -70,7 +70,7 @@ func (c *GetInstanceGroupsCmd) Run(args []string) error { m := make(map[string]*api.InstanceGroup) for i := range list.Items { ig := &list.Items[i] - m[ig.Name] = ig + m[ig.ObjectMeta.Name] = ig } instancegroups = make([]*api.InstanceGroup, 0, len(args)) for _, arg := range args { @@ -97,7 +97,7 @@ func (c *GetInstanceGroupsCmd) Run(args []string) error { if output == OutputTable { t := &tables.Table{} t.AddColumn("NAME", func(c *api.InstanceGroup) string { - return c.Name + return c.ObjectMeta.Name }) t.AddColumn("ROLE", func(c *api.InstanceGroup) string { return string(c.Spec.Role) @@ -119,7 +119,7 @@ func (c *GetInstanceGroupsCmd) Run(args []string) error { for _, ig := range instancegroups { y, err := api.ToYaml(ig) if err != nil { - return fmt.Errorf("error marshaling yaml for %q: %v", ig.Name, err) + return fmt.Errorf("error marshaling yaml for %q: %v", ig.ObjectMeta.Name, err) } _, err = os.Stdout.Write(y) if err != nil { diff --git a/cmd/kops/rollingupdate_cluster.go b/cmd/kops/rollingupdate_cluster.go index fb862700712d8..e5ea4d750825e 100644 --- a/cmd/kops/rollingupdate_cluster.go +++ b/cmd/kops/rollingupdate_cluster.go @@ -84,7 +84,7 @@ func (c *RollingUpdateClusterCmd) Run(args []string) error { return err } - contextName := cluster.Name + contextName := cluster.ObjectMeta.Name config, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig( clientcmd.NewDefaultClientConfigLoadingRules(), &clientcmd.ConfigOverrides{CurrentContext: contextName}).ClientConfig() @@ -112,7 +112,7 @@ func (c *RollingUpdateClusterCmd) Run(args []string) error { } } - list, err := clientset.InstanceGroups(cluster.Name).List(k8sapi.ListOptions{}) + list, err := clientset.InstanceGroups(cluster.ObjectMeta.Name).List(k8sapi.ListOptions{}) if err != nil { return err } @@ -142,7 +142,7 @@ func (c *RollingUpdateClusterCmd) Run(args []string) error { { t := &tables.Table{} t.AddColumn("NAME", func(r *kutil.CloudInstanceGroup) string { - return r.InstanceGroup.Name + return r.InstanceGroup.ObjectMeta.Name }) t.AddColumn("STATUS", func(r *kutil.CloudInstanceGroup) string { return r.Status diff --git a/cmd/kops/root.go b/cmd/kops/root.go index 5fd7083feaea6..ba639fa40c86a 100644 --- a/cmd/kops/root.go +++ b/cmd/kops/root.go @@ -239,8 +239,8 @@ func (c *RootCmd) Cluster() (*kopsapi.Cluster, error) { return nil, fmt.Errorf("cluster %q not found", clusterName) } - if clusterName != cluster.Name { - return nil, fmt.Errorf("cluster name did not match expected name: %v vs %v", clusterName, cluster.Name) + if clusterName != cluster.ObjectMeta.Name { + return nil, fmt.Errorf("cluster name did not match expected name: %v vs %v", clusterName, cluster.ObjectMeta.Name) } return cluster, nil } diff --git a/cmd/kops/toolbox_convert_imported.go b/cmd/kops/toolbox_convert_imported.go index 7972abe3930d5..83686565101c0 100644 --- a/cmd/kops/toolbox_convert_imported.go +++ b/cmd/kops/toolbox_convert_imported.go @@ -63,7 +63,7 @@ func (c *ConvertImportedCmd) Run() error { return err } - list, err := clientset.InstanceGroups(cluster.Name).List(k8sapi.ListOptions{}) + list, err := clientset.InstanceGroups(cluster.ObjectMeta.Name).List(k8sapi.ListOptions{}) if err != nil { return err } @@ -72,15 +72,15 @@ func (c *ConvertImportedCmd) Run() error { instanceGroups = append(instanceGroups, &list.Items[i]) } - if cluster.Annotations[api.AnnotationNameManagement] != api.AnnotationValueManagementImported { - return fmt.Errorf("cluster %q does not appear to be a cluster imported using kops import", cluster.Name) + if cluster.ObjectMeta.Annotations[api.AnnotationNameManagement] != api.AnnotationValueManagementImported { + return fmt.Errorf("cluster %q does not appear to be a cluster imported using kops import", cluster.ObjectMeta.Name) } if c.NewClusterName == "" { return fmt.Errorf("--newname is required for converting an imported cluster") } - oldClusterName := cluster.Name + oldClusterName := cluster.ObjectMeta.Name if oldClusterName == "" { return fmt.Errorf("(Old) ClusterName must be set in configuration") } diff --git a/cmd/kops/update_cluster.go b/cmd/kops/update_cluster.go index 31750fd7bfa80..ab989ccba6959 100644 --- a/cmd/kops/update_cluster.go +++ b/cmd/kops/update_cluster.go @@ -115,7 +115,7 @@ func RunUpdateCluster(f *util.Factory, cmd *cobra.Command, args []string, out io } if c.SSHPublicKey != "" { - fmt.Fprintf(out, "--ssh-public-key on update is deprecated - please use `kops create secret --name %s sshpublickey admin -i ~/.ssh/id_rsa.pub` instead\n", cluster.Name) + fmt.Fprintf(out, "--ssh-public-key on update is deprecated - please use `kops create secret --name %s sshpublickey admin -i ~/.ssh/id_rsa.pub` instead\n", cluster.ObjectMeta.Name) c.SSHPublicKey = utils.ExpandPath(c.SSHPublicKey) authorized, err := ioutil.ReadFile(c.SSHPublicKey) @@ -153,7 +153,7 @@ func RunUpdateCluster(f *util.Factory, cmd *cobra.Command, args []string, out io // TODO: Only if not yet set? if !isDryrun { - hasKubecfg, err := hasKubecfg(cluster.Name) + hasKubecfg, err := hasKubecfg(cluster.ObjectMeta.Name) if err != nil { glog.Warningf("error reading kubecfg: %v", err) hasKubecfg = true @@ -168,7 +168,7 @@ func RunUpdateCluster(f *util.Factory, cmd *cobra.Command, args []string, out io if kubecfgCert != nil { glog.Infof("Exporting kubecfg for cluster") x := &kutil.CreateKubecfg{ - ContextName: cluster.Name, + ContextName: cluster.ObjectMeta.Name, KeyStore: keyStore, SecretStore: secretStore, KubeMasterIP: cluster.Spec.MasterPublicName, diff --git a/cmd/kops/upgrade_cluster.go b/cmd/kops/upgrade_cluster.go index 757c135a07997..b7802f5fea58c 100644 --- a/cmd/kops/upgrade_cluster.go +++ b/cmd/kops/upgrade_cluster.go @@ -80,7 +80,7 @@ func (c *UpgradeClusterCmd) Run(args []string) error { return err } - list, err := clientset.InstanceGroups(cluster.Name).List(k8sapi.ListOptions{}) + list, err := clientset.InstanceGroups(cluster.ObjectMeta.Name).List(k8sapi.ListOptions{}) if err != nil { return err } @@ -90,7 +90,7 @@ func (c *UpgradeClusterCmd) Run(args []string) error { instanceGroups = append(instanceGroups, &list.Items[i]) } - if cluster.Annotations[api.AnnotationNameManagement] == api.AnnotationValueManagementImported { + if cluster.ObjectMeta.Annotations[api.AnnotationNameManagement] == api.AnnotationValueManagementImported { return fmt.Errorf("upgrade is not for use with imported clusters (did you mean `kops toolbox convert-imported`?)") } @@ -181,7 +181,7 @@ func (c *UpgradeClusterCmd) Run(args []string) error { if ig.Spec.Image != image.Name { target := ig actions = append(actions, &upgradeAction{ - Item: "InstanceGroup/" + target.Name, + Item: "InstanceGroup/" + target.ObjectMeta.Name, Property: "Image", Old: target.Spec.Image, New: image.Name, @@ -275,16 +275,16 @@ func (c *UpgradeClusterCmd) Run(args []string) error { } for _, g := range instanceGroups { - _, err := clientset.InstanceGroups(cluster.Name).Update(g) + _, err := clientset.InstanceGroups(cluster.ObjectMeta.Name).Update(g) if err != nil { - return fmt.Errorf("error writing InstanceGroup %q: %v", g.Name, err) + return fmt.Errorf("error writing InstanceGroup %q: %v", g.ObjectMeta.Name, err) } } fmt.Printf("\nUpdates applied to configuration.\n") // TODO: automate this step - fmt.Printf("You can now apply these changes, using `kops update cluster %s`\n", cluster.Name) + fmt.Printf("You can now apply these changes, using `kops update cluster %s`\n", cluster.ObjectMeta.Name) } return nil diff --git a/cmd/kops/validate_cluster.go b/cmd/kops/validate_cluster.go index 3975d26f6238c..2653c23e6e262 100644 --- a/cmd/kops/validate_cluster.go +++ b/cmd/kops/validate_cluster.go @@ -72,12 +72,12 @@ func RunValidateCluster(f *util.Factory, cmd *cobra.Command, args []string, out return err } - list, err := clientSet.InstanceGroups(cluster.Name).List(k8sapi.ListOptions{}) + list, err := clientSet.InstanceGroups(cluster.ObjectMeta.Name).List(k8sapi.ListOptions{}) if err != nil { - return fmt.Errorf("cannot get InstanceGroups for %q: %v", cluster.Name, err) + return fmt.Errorf("cannot get InstanceGroups for %q: %v", cluster.ObjectMeta.Name, err) } - fmt.Fprintf(out, "Validating cluster %v\n\n", cluster.Name) + fmt.Fprintf(out, "Validating cluster %v\n\n", cluster.ObjectMeta.Name) var instanceGroups []*api.InstanceGroup for _, ig := range list.Items { @@ -89,7 +89,7 @@ func RunValidateCluster(f *util.Factory, cmd *cobra.Command, args []string, out } // TODO: Refactor into util.Factory - contextName := cluster.Name + contextName := cluster.ObjectMeta.Name config, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig( clientcmd.NewDefaultClientConfigLoadingRules(), &clientcmd.ConfigOverrides{CurrentContext: contextName}).ClientConfig() @@ -102,15 +102,15 @@ func RunValidateCluster(f *util.Factory, cmd *cobra.Command, args []string, out return fmt.Errorf("cannot build kube client for %q: %v", contextName, err) } - validationCluster, validationFailed := validation.ValidateCluster(cluster.Name, list, k8sClient) + validationCluster, validationFailed := validation.ValidateCluster(cluster.ObjectMeta.Name, list, k8sClient) if validationCluster.NodeList == nil { - return fmt.Errorf("cannot get nodes for %q: %v", cluster.Name, validationFailed) + return fmt.Errorf("cannot get nodes for %q: %v", cluster.ObjectMeta.Name, validationFailed) } t := &tables.Table{} t.AddColumn("NAME", func(c *api.InstanceGroup) string { - return c.Name + return c.ObjectMeta.Name }) t.AddColumn("ROLE", func(c *api.InstanceGroup) string { return string(c.Spec.Role) @@ -132,7 +132,7 @@ func RunValidateCluster(f *util.Factory, cmd *cobra.Command, args []string, out err = t.Render(instanceGroups, out, "NAME", "ROLE", "MACHINETYPE", "MIN", "MAX", "ZONES") if err != nil { - return fmt.Errorf("cannot render nodes for %q: %v", cluster.Name, err) + return fmt.Errorf("cannot render nodes for %q: %v", cluster.ObjectMeta.Name, err) } t = &tables.Table{} @@ -159,11 +159,11 @@ func RunValidateCluster(f *util.Factory, cmd *cobra.Command, args []string, out err = t.Render(validationCluster.NodeList.Items, out, "NAME", "ROLE", "READY") if err != nil { - return fmt.Errorf("cannot render nodes for %q: %v", cluster.Name, err) + return fmt.Errorf("cannot render nodes for %q: %v", cluster.ObjectMeta.Name, err) } if validationFailed == nil { - fmt.Fprintf(out, "\nYour cluster %s is ready\n", cluster.Name) + fmt.Fprintf(out, "\nYour cluster %s is ready\n", cluster.ObjectMeta.Name) return nil } else { // do we need to print which instance group is not ready? @@ -173,7 +173,7 @@ func RunValidateCluster(f *util.Factory, cmd *cobra.Command, args []string, out fmt.Fprintf(out, "mastersCount %v, mastersReady %v", validationCluster.MastersCount, len(validationCluster.MastersReadyArray)) fmt.Fprintf(out, "nodesNotReady %v", len(validationCluster.NodesNotReadyArray)) fmt.Fprintf(out, "nodesCount %v, nodesReady %v", validationCluster.NodesCount, len(validationCluster.NodesReadyArray)) - return fmt.Errorf("\nYour cluster %s is NOT ready.", cluster.Name) + return fmt.Errorf("\nYour cluster %s is NOT ready.", cluster.ObjectMeta.Name) } } diff --git a/federation/apply_federation.go b/federation/apply_federation.go index 8460d3206091e..1773726780603 100644 --- a/federation/apply_federation.go +++ b/federation/apply_federation.go @@ -156,7 +156,7 @@ func (o *ApplyFederationOperation) Run() error { return fmt.Errorf("error reading cluster %q: %v", member, err) } - clusterName := strings.Replace(cluster.Name, ".", "-", -1) + clusterName := strings.Replace(cluster.ObjectMeta.Name, ".", "-", -1) a := &FederationCluster{ FederationNamespace: o.namespace, @@ -164,7 +164,7 @@ func (o *ApplyFederationOperation) Run() error { ControllerKubernetesClients: controllerKubernetesClients, FederationClient: federationControllerClient, - ClusterSecretName: "secret-" + cluster.Name, + ClusterSecretName: "secret-" + cluster.ObjectMeta.Name, ClusterName: clusterName, ApiserverHostname: cluster.Spec.MasterPublicName, } @@ -210,7 +210,7 @@ func (o *ApplyFederationOperation) buildApiserverKeypair() *fitasks.Keypair { keypairName := "secret-" + o.apiserverHostName keypair := &fitasks.Keypair{ Name: fi.String(keypairName), - Subject: "cn=" + o.Federation.Name, + Subject: "cn=" + o.Federation.ObjectMeta.Name, Type: "server", } diff --git a/federation/federation_cluster.go b/federation/federation_cluster.go index e47c65ca832a0..cf7ab2688472f 100644 --- a/federation/federation_cluster.go +++ b/federation/federation_cluster.go @@ -52,7 +52,7 @@ func (o *FederationCluster) Run(cluster *kopsapi.Cluster) error { } k := kutil.CreateKubecfg{ - ContextName: cluster.Name, + ContextName: cluster.ObjectMeta.Name, KeyStore: keyStore, SecretStore: secretStore, KubeMasterIP: cluster.Spec.MasterPublicName, @@ -60,7 +60,7 @@ func (o *FederationCluster) Run(cluster *kopsapi.Cluster) error { kubeconfig, err := k.ExtractKubeconfig() if err != nil { - return fmt.Errorf("error building connection information for cluster %q: %v", cluster.Name, err) + return fmt.Errorf("error building connection information for cluster %q: %v", cluster.ObjectMeta.Name, err) } user := kutil.KubectlUser{ diff --git a/federation/federation_configuration.go b/federation/federation_configuration.go index f21785f68b2e8..71b853a73c1da 100644 --- a/federation/federation_configuration.go +++ b/federation/federation_configuration.go @@ -47,7 +47,7 @@ func (o *FederationConfiguration) extractKubecfg(c *fi.Context, f *kopsapi.Feder k := kutil.NewKubeconfigBuilder() k.KubeMasterIP = masterName - k.Context = "federation-" + f.Name + k.Context = "federation-" + f.ObjectMeta.Name // CA Cert caCert, _, err := c.Keystore.FindKeypair(fi.CertificateId_CA) diff --git a/federation/targets/kubernetes/kubernetestarget.go b/federation/targets/kubernetes/kubernetestarget.go index 6981f94288ea6..0dccaac6b6411 100644 --- a/federation/targets/kubernetes/kubernetestarget.go +++ b/federation/targets/kubernetes/kubernetestarget.go @@ -34,7 +34,7 @@ type KubernetesTarget struct { func NewKubernetesTarget(clientset simple.Clientset, keystore fi.Keystore, cluster *kopsapi.Cluster) (*KubernetesTarget, error) { b := &kutil.CreateKubecfg{ - ContextName: cluster.Name, + ContextName: cluster.ObjectMeta.Name, KeyStore: keystore, SecretStore: nil, KubeMasterIP: cluster.Spec.MasterPublicName, @@ -42,12 +42,12 @@ func NewKubernetesTarget(clientset simple.Clientset, keystore fi.Keystore, clust kubeconfig, err := b.ExtractKubeconfig() if err != nil { - return nil, fmt.Errorf("error building credentials for cluster %q: %v", cluster.Name, err) + return nil, fmt.Errorf("error building credentials for cluster %q: %v", cluster.ObjectMeta.Name, err) } clientConfig, err := kubeconfig.BuildRestConfig() if err != nil { - return nil, fmt.Errorf("error building configuration for cluster %q: %v", cluster.Name, err) + return nil, fmt.Errorf("error building configuration for cluster %q: %v", cluster.ObjectMeta.Name, err) } k8sClient, err := release_1_5.NewForConfig(clientConfig) @@ -70,7 +70,7 @@ func (t *KubernetesTarget) Finish(taskMap map[string]fi.Task) error { } func (t *KubernetesTarget) Apply(manifest []byte) error { - context := t.cluster.Name + context := t.cluster.ObjectMeta.Name // Would be nice if we could use RunApply from kubectl's code directly... // ... but that seems really hard diff --git a/pkg/apis/kops/channel.go b/pkg/apis/kops/channel.go index 1fe81bf6861df..8065d63ab6016 100644 --- a/pkg/apis/kops/channel.go +++ b/pkg/apis/kops/channel.go @@ -21,6 +21,7 @@ import ( "github.com/golang/glog" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/util/pkg/vfs" + "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/unversioned" "net/url" ) @@ -30,7 +31,7 @@ const DefaultChannel = "stable" type Channel struct { unversioned.TypeMeta `json:",inline"` - ObjectMeta `json:"metadata,omitempty"` + ObjectMeta api.ObjectMeta `json:"metadata,omitempty"` Spec ChannelSpec `json:"spec,omitempty"` } diff --git a/pkg/apis/kops/cluster.go b/pkg/apis/kops/cluster.go index 6e6ae1e8f1f80..57126773f2941 100644 --- a/pkg/apis/kops/cluster.go +++ b/pkg/apis/kops/cluster.go @@ -24,17 +24,21 @@ import ( "github.com/golang/glog" "k8s.io/kops/util/pkg/vfs" + "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/unversioned" ) type Cluster struct { unversioned.TypeMeta `json:",inline"` - ObjectMeta `json:"metadata,omitempty"` + ObjectMeta api.ObjectMeta `json:"metadata,omitempty"` Spec ClusterSpec `json:"spec,omitempty"` } type ClusterList struct { + unversioned.TypeMeta `json:",inline"` + unversioned.ListMeta `json:"metadata,omitempty"` + Items []Cluster `json:"items"` } @@ -318,8 +322,8 @@ func (c *Cluster) PerformAssignments() error { } // TODO: Unclear this should be here - it isn't too hard to change - if c.Spec.MasterPublicName == "" && c.Name != "" { - c.Spec.MasterPublicName = "api." + c.Name + if c.Spec.MasterPublicName == "" && c.ObjectMeta.Name != "" { + c.Spec.MasterPublicName = "api." + c.ObjectMeta.Name } for _, zone := range c.Spec.Zones { @@ -371,16 +375,16 @@ func (c *Cluster) FillDefaults() error { return err } - if c.Name == "" { + if c.ObjectMeta.Name == "" { return fmt.Errorf("cluster Name not set in FillDefaults") } if c.Spec.MasterInternalName == "" { - c.Spec.MasterInternalName = "api.internal." + c.Name + c.Spec.MasterInternalName = "api.internal." + c.ObjectMeta.Name } if c.Spec.MasterPublicName == "" { - c.Spec.MasterPublicName = "api." + c.Name + c.Spec.MasterPublicName = "api." + c.ObjectMeta.Name } return nil diff --git a/pkg/apis/kops/componentconfig.go b/pkg/apis/kops/componentconfig.go index fe52971f12fb1..92e23a42245c1 100644 --- a/pkg/apis/kops/componentconfig.go +++ b/pkg/apis/kops/componentconfig.go @@ -16,19 +16,15 @@ limitations under the License. package kops -import ( - "k8s.io/kubernetes/pkg/api/unversioned" -) - // Configuration for each component // Wherever possible, we try to use the types & names in https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/componentconfig/types.go -type KubeletConfig struct { - unversioned.TypeMeta `json:",inline"` - ObjectMeta `json:"metadata,omitempty"` - - Spec ClusterSpec `json:"spec,omitempty"` -} +//type KubeletConfig struct { +// unversioned.TypeMeta `json:",inline"` +// ObjectMeta api.ObjectMeta `json:"metadata,omitempty"` +// +// Spec ClusterSpec `json:"spec,omitempty"` +//} type KubeletConfigSpec struct { APIServers string `json:"apiServers,omitempty" flag:"api-servers"` diff --git a/pkg/apis/kops/federation.go b/pkg/apis/kops/federation.go index a0626d4e5c49a..9a23c3eb04ded 100644 --- a/pkg/apis/kops/federation.go +++ b/pkg/apis/kops/federation.go @@ -17,13 +17,14 @@ limitations under the License. package kops import ( + "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/unversioned" ) // Federation represents a federated set of kubernetes clusters type Federation struct { unversioned.TypeMeta `json:",inline"` - ObjectMeta `json:"metadata,omitempty"` + ObjectMeta api.ObjectMeta `json:"metadata,omitempty"` Spec FederationSpec `json:"spec,omitempty"` } diff --git a/pkg/apis/kops/hack.go b/pkg/apis/kops/hack.go deleted file mode 100644 index 3f61606afdc5a..0000000000000 --- a/pkg/apis/kops/hack.go +++ /dev/null @@ -1,124 +0,0 @@ -/* -Copyright 2016 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 kops - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/types" -) - -// ObjectMeta is metadata that all persisted resources must have, which includes all objects -// users must create. -type ObjectMeta struct { - // Name is unique within a namespace. Name is required when creating resources, although - // some resources may allow a client to request the generation of an appropriate name - // automatically. Name is primarily intended for creation idempotence and configuration - // definition. - Name string `json:"name,omitempty"` - - // GenerateName indicates that the name should be made unique by the server prior to persisting - // it. A non-empty value for the field indicates the name will be made unique (and the name - // returned to the client will be different than the name passed). The value of this field will - // be combined with a unique suffix on the server if the Name field has not been provided. - // The provided value must be valid within the rules for Name, and may be truncated by the length - // of the suffix required to make the value unique on the server. - // - // If this field is specified, and Name is not present, the server will NOT return a 409 if the - // generated name exists - instead, it will either return 201 Created or 500 with Reason - // ServerTimeout indicating a unique name could not be found in the time allotted, and the client - // should retry (optionally after the time indicated in the Retry-After header). - GenerateName string `json:"generateName,omitempty"` - - // Namespace defines the space within which name must be unique. An empty namespace is - // equivalent to the "default" namespace, but "default" is the canonical representation. - // Not all objects are required to be scoped to a namespace - the value of this field for - // those objects will be empty. - Namespace string `json:"namespace,omitempty"` - - // SelfLink is a URL representing this object. - SelfLink string `json:"selfLink,omitempty"` - - // UID is the unique in time and space value for this object. It is typically generated by - // the server on successful creation of a resource and is not allowed to change on PUT - // operations. - UID types.UID `json:"uid,omitempty"` - - // An opaque value that represents the version of this resource. May be used for optimistic - // concurrency, change detection, and the watch operation on a resource or set of resources. - // Clients must treat these values as opaque and values may only be valid for a particular - // resource or set of resources. Only servers will generate resource versions. - ResourceVersion string `json:"resourceVersion,omitempty"` - - // A sequence number representing a specific generation of the desired state. - // Populated by the system. Read-only. - Generation int64 `json:"generation,omitempty"` - - // CreationTimestamp is a timestamp representing the server time when this object was - // created. It is not guaranteed to be set in happens-before order across separate operations. - // Clients may not set this value. It is represented in RFC3339 form and is in UTC. - CreationTimestamp unversioned.Time `json:"creationTimestamp,omitempty"` - - // DeletionTimestamp is the time after which this resource will be deleted. This - // field is set by the server when a graceful deletion is requested by the user, and is not - // directly settable by a client. The resource will be deleted (no longer visible from - // resource lists, and not reachable by name) after the time in this field. Once set, this - // value may not be unset or be set further into the future, although it may be shortened - // or the resource may be deleted prior to this time. For example, a user may request that - // a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination - // signal to the containers in the pod. Once the resource is deleted in the API, the Kubelet - // will send a hard termination signal to the container. - DeletionTimestamp *unversioned.Time `json:"deletionTimestamp,omitempty"` - - // DeletionGracePeriodSeconds records the graceful deletion value set when graceful deletion - // was requested. Represents the most recent grace period, and may only be shortened once set. - DeletionGracePeriodSeconds *int64 `json:"deletionGracePeriodSeconds,omitempty"` - - // Labels are key value pairs that may be used to scope and select individual resources. - // Label keys are of the form: - // label-key ::= prefixed-name | name - // prefixed-name ::= prefix '/' name - // prefix ::= DNS_SUBDOMAIN - // name ::= DNS_LABEL - // The prefix is optional. If the prefix is not specified, the key is assumed to be private - // to the user. Other system components that wish to use labels must specify a prefix. The - // "kubernetes.io/" prefix is reserved for use by kubernetes components. - Labels map[string]string `json:"labels,omitempty"` - - // Annotations are unstructured key value data stored with a resource that may be set by - // external tooling. They are not queryable and should be preserved when modifying - // objects. Annotation keys have the same formatting restrictions as Label keys. See the - // comments on Labels for details. - Annotations map[string]string `json:"annotations,omitempty"` - - // List of objects depended by this object. If ALL objects in the list have - // been deleted, this object will be garbage collected. If this object is managed by a controller, - // then an entry in this list will point to this controller, with the controller field set to true. - // There cannot be more than one managing controller. - OwnerReferences []api.OwnerReference `json:"ownerReferences,omitempty"` - - // Must be empty before the object is deleted from the registry. Each entry - // is an identifier for the responsible component that will remove the entry - // from the list. If the deletionTimestamp of the object is non-nil, entries - // in this list can only be removed. - Finalizers []string `json:"finalizers,omitempty"` - - // The name of the cluster which the object belongs to. - // This is used to distinguish resources with same name and namespace in different clusters. - // This field is not set anywhere right now and apiserver is going to ignore it if set in create or update request. - ClusterName string `json:"clusterName,omitempty"` -} diff --git a/pkg/apis/kops/instancegroup.go b/pkg/apis/kops/instancegroup.go index 9397b89c8e3a0..d5f889cd07320 100644 --- a/pkg/apis/kops/instancegroup.go +++ b/pkg/apis/kops/instancegroup.go @@ -19,6 +19,7 @@ package kops import ( "fmt" "github.com/golang/glog" + "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/util/validation/field" ) @@ -26,12 +27,15 @@ import ( // InstanceGroup represents a group of instances (either nodes or masters) with the same configuration type InstanceGroup struct { unversioned.TypeMeta `json:",inline"` - ObjectMeta `json:"metadata,omitempty"` + ObjectMeta api.ObjectMeta `json:"metadata,omitempty"` Spec InstanceGroupSpec `json:"spec,omitempty"` } type InstanceGroupList struct { + unversioned.TypeMeta `json:",inline"` + unversioned.ListMeta `json:"metadata,omitempty"` + Items []InstanceGroup `json:"items"` } @@ -79,18 +83,18 @@ type InstanceGroupSpec struct { func PerformAssignmentsInstanceGroups(groups []*InstanceGroup) error { names := map[string]bool{} for _, group := range groups { - names[group.Name] = true + names[group.ObjectMeta.Name] = true } for _, group := range groups { // We want to give them a stable Name as soon as possible - if group.Name == "" { + if group.ObjectMeta.Name == "" { // Loop to find the first unassigned name like `nodes-%d` i := 0 for { key := fmt.Sprintf("nodes-%d", i) if !names[key] { - group.Name = key + group.ObjectMeta.Name = key names[key] = true break } @@ -116,7 +120,7 @@ func (g *InstanceGroup) IsMaster() bool { } func (g *InstanceGroup) Validate() error { - if g.Name == "" { + if g.ObjectMeta.Name == "" { return field.Required(field.NewPath("Name"), "") } @@ -134,7 +138,7 @@ func (g *InstanceGroup) Validate() error { if g.IsMaster() { if len(g.Spec.Zones) == 0 { - return fmt.Errorf("Master InstanceGroup %s did not specify any Zones", g.Name) + return fmt.Errorf("Master InstanceGroup %s did not specify any Zones", g.ObjectMeta.Name) } } @@ -161,7 +165,7 @@ func (g *InstanceGroup) CrossValidate(cluster *Cluster, strict bool) error { for _, z := range g.Spec.Zones { if clusterZones[z] == nil { - return fmt.Errorf("InstanceGroup %q is configured in %q, but this is not configured as a Zone in the cluster", g.Name, z) + return fmt.Errorf("InstanceGroup %q is configured in %q, but this is not configured as a Zone in the cluster", g.ObjectMeta.Name, z) } } } diff --git a/pkg/apis/kops/registry/helpers.go b/pkg/apis/kops/registry/helpers.go index a0f1b62e81f07..1d7334e9a0424 100644 --- a/pkg/apis/kops/registry/helpers.go +++ b/pkg/apis/kops/registry/helpers.go @@ -27,13 +27,13 @@ func CreateClusterConfig(clientset simple.Clientset, cluster *api.Cluster, group { names := map[string]bool{} for i, ns := range groups { - if ns.Name == "" { + if ns.ObjectMeta.Name == "" { return fmt.Errorf("InstanceGroup #%d did not have a Name", i+1) } - if names[ns.Name] { - return fmt.Errorf("Duplicate InstanceGroup Name found: %q", ns.Name) + if names[ns.ObjectMeta.Name] { + return fmt.Errorf("Duplicate InstanceGroup Name found: %q", ns.ObjectMeta.Name) } - names[ns.Name] = true + names[ns.ObjectMeta.Name] = true } } @@ -43,7 +43,7 @@ func CreateClusterConfig(clientset simple.Clientset, cluster *api.Cluster, group } for _, ig := range groups { - _, err = clientset.InstanceGroups(cluster.Name).Create(ig) + _, err = clientset.InstanceGroups(cluster.ObjectMeta.Name).Create(ig) if err != nil { return fmt.Errorf("error writing updated instancegroup configuration: %v", err) } diff --git a/pkg/apis/kops/v1alpha1/cluster.go b/pkg/apis/kops/v1alpha1/cluster.go index 3ef94b2fdaa16..2cafaa06f988b 100644 --- a/pkg/apis/kops/v1alpha1/cluster.go +++ b/pkg/apis/kops/v1alpha1/cluster.go @@ -17,12 +17,13 @@ limitations under the License. package v1alpha1 import ( + "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/unversioned" ) type Cluster struct { unversioned.TypeMeta `json:",inline"` - ObjectMeta `json:"metadata,omitempty"` + ObjectMeta api.ObjectMeta `json:"metadata,omitempty"` // Spec defines the behavior of a Cluster. Spec ClusterSpec `json:"spec,omitempty"` diff --git a/pkg/apis/kops/v1alpha1/componentconfig.go b/pkg/apis/kops/v1alpha1/componentconfig.go index 9ec58c7597fc7..b35f64564fd1d 100644 --- a/pkg/apis/kops/v1alpha1/componentconfig.go +++ b/pkg/apis/kops/v1alpha1/componentconfig.go @@ -16,19 +16,15 @@ limitations under the License. package v1alpha1 -import ( - "k8s.io/kubernetes/pkg/api/unversioned" -) - // Configuration for each component // Wherever possible, we try to use the types & names in https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/componentconfig/types.go -type KubeletConfig struct { - unversioned.TypeMeta `json:",inline"` - ObjectMeta `json:"metadata,omitempty"` - - Spec ClusterSpec `json:"spec,omitempty"` -} +//type KubeletConfig struct { +// unversioned.TypeMeta `json:",inline"` +// ObjectMeta api.ObjectMeta `json:"metadata,omitempty"` +// +// Spec ClusterSpec `json:"spec,omitempty"` +//} type KubeletConfigSpec struct { APIServers string `json:"apiServers,omitempty" flag:"api-servers"` diff --git a/pkg/apis/kops/v1alpha1/federation.go b/pkg/apis/kops/v1alpha1/federation.go index 6b6a8dd974927..2e30eac6e98a7 100644 --- a/pkg/apis/kops/v1alpha1/federation.go +++ b/pkg/apis/kops/v1alpha1/federation.go @@ -17,12 +17,13 @@ limitations under the License. package v1alpha1 import ( + "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/unversioned" ) type Federation struct { unversioned.TypeMeta `json:",inline"` - ObjectMeta `json:"metadata,omitempty"` + ObjectMeta api.ObjectMeta `json:"metadata,omitempty"` Spec FederationSpec `json:"spec"` } diff --git a/pkg/apis/kops/v1alpha1/hack.go b/pkg/apis/kops/v1alpha1/hack.go deleted file mode 100644 index 2c5e8d598693b..0000000000000 --- a/pkg/apis/kops/v1alpha1/hack.go +++ /dev/null @@ -1,124 +0,0 @@ -/* -Copyright 2016 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 v1alpha1 - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/types" -) - -// ObjectMeta is metadata that all persisted resources must have, which includes all objects -// users must create. -type ObjectMeta struct { - // Name is unique within a namespace. Name is required when creating resources, although - // some resources may allow a client to request the generation of an appropriate name - // automatically. Name is primarily intended for creation idempotence and configuration - // definition. - Name string `json:"name,omitempty"` - - // GenerateName indicates that the name should be made unique by the server prior to persisting - // it. A non-empty value for the field indicates the name will be made unique (and the name - // returned to the client will be different than the name passed). The value of this field will - // be combined with a unique suffix on the server if the Name field has not been provided. - // The provided value must be valid within the rules for Name, and may be truncated by the length - // of the suffix required to make the value unique on the server. - // - // If this field is specified, and Name is not present, the server will NOT return a 409 if the - // generated name exists - instead, it will either return 201 Created or 500 with Reason - // ServerTimeout indicating a unique name could not be found in the time allotted, and the client - // should retry (optionally after the time indicated in the Retry-After header). - GenerateName string `json:"generateName,omitempty"` - - // Namespace defines the space within which name must be unique. An empty namespace is - // equivalent to the "default" namespace, but "default" is the canonical representation. - // Not all objects are required to be scoped to a namespace - the value of this field for - // those objects will be empty. - Namespace string `json:"namespace,omitempty"` - - // SelfLink is a URL representing this object. - SelfLink string `json:"selfLink,omitempty"` - - // UID is the unique in time and space value for this object. It is typically generated by - // the server on successful creation of a resource and is not allowed to change on PUT - // operations. - UID types.UID `json:"uid,omitempty"` - - // An opaque value that represents the version of this resource. May be used for optimistic - // concurrency, change detection, and the watch operation on a resource or set of resources. - // Clients must treat these values as opaque and values may only be valid for a particular - // resource or set of resources. Only servers will generate resource versions. - ResourceVersion string `json:"resourceVersion,omitempty"` - - // A sequence number representing a specific generation of the desired state. - // Populated by the system. Read-only. - Generation int64 `json:"generation,omitempty"` - - // CreationTimestamp is a timestamp representing the server time when this object was - // created. It is not guaranteed to be set in happens-before order across separate operations. - // Clients may not set this value. It is represented in RFC3339 form and is in UTC. - CreationTimestamp unversioned.Time `json:"creationTimestamp,omitempty"` - - // DeletionTimestamp is the time after which this resource will be deleted. This - // field is set by the server when a graceful deletion is requested by the user, and is not - // directly settable by a client. The resource will be deleted (no longer visible from - // resource lists, and not reachable by name) after the time in this field. Once set, this - // value may not be unset or be set further into the future, although it may be shortened - // or the resource may be deleted prior to this time. For example, a user may request that - // a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination - // signal to the containers in the pod. Once the resource is deleted in the API, the Kubelet - // will send a hard termination signal to the container. - DeletionTimestamp *unversioned.Time `json:"deletionTimestamp,omitempty"` - - // DeletionGracePeriodSeconds records the graceful deletion value set when graceful deletion - // was requested. Represents the most recent grace period, and may only be shortened once set. - DeletionGracePeriodSeconds *int64 `json:"deletionGracePeriodSeconds,omitempty"` - - // Labels are key value pairs that may be used to scope and select individual resources. - // Label keys are of the form: - // label-key ::= prefixed-name | name - // prefixed-name ::= prefix '/' name - // prefix ::= DNS_SUBDOMAIN - // name ::= DNS_LABEL - // The prefix is optional. If the prefix is not specified, the key is assumed to be private - // to the user. Other system components that wish to use labels must specify a prefix. The - // "kubernetes.io/" prefix is reserved for use by kubernetes components. - Labels map[string]string `json:"labels,omitempty"` - - // Annotations are unstructured key value data stored with a resource that may be set by - // external tooling. They are not queryable and should be preserved when modifying - // objects. Annotation keys have the same formatting restrictions as Label keys. See the - // comments on Labels for details. - Annotations map[string]string `json:"annotations,omitempty"` - - // List of objects depended by this object. If ALL objects in the list have - // been deleted, this object will be garbage collected. If this object is managed by a controller, - // then an entry in this list will point to this controller, with the controller field set to true. - // There cannot be more than one managing controller. - OwnerReferences []api.OwnerReference `json:"ownerReferences,omitempty"` - - // Must be empty before the object is deleted from the registry. Each entry - // is an identifier for the responsible component that will remove the entry - // from the list. If the deletionTimestamp of the object is non-nil, entries - // in this list can only be removed. - Finalizers []string `json:"finalizers,omitempty"` - - // The name of the cluster which the object belongs to. - // This is used to distinguish resources with same name and namespace in different clusters. - // This field is not set anywhere right now and apiserver is going to ignore it if set in create or update request. - ClusterName string `json:"clusterName,omitempty"` -} diff --git a/pkg/apis/kops/v1alpha1/instancegroup.go b/pkg/apis/kops/v1alpha1/instancegroup.go index 8969282a1899d..764ab5bfd382a 100644 --- a/pkg/apis/kops/v1alpha1/instancegroup.go +++ b/pkg/apis/kops/v1alpha1/instancegroup.go @@ -17,13 +17,14 @@ limitations under the License. package v1alpha1 import ( + "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/unversioned" ) // InstanceGroup represents a group of instances (either nodes or masters) with the same configuration type InstanceGroup struct { unversioned.TypeMeta `json:",inline"` - ObjectMeta `json:"metadata,omitempty"` + ObjectMeta api.ObjectMeta `json:"metadata,omitempty"` Spec InstanceGroupSpec `json:"spec,omitempty"` } diff --git a/pkg/apis/kops/validation.go b/pkg/apis/kops/validation.go index 597bdeedfc8f3..5290916c8596d 100644 --- a/pkg/apis/kops/validation.go +++ b/pkg/apis/kops/validation.go @@ -35,20 +35,20 @@ func (c *Cluster) Validate(strict bool) error { specPath := field.NewPath("Cluster").Child("Spec") - if c.Name == "" { + if c.ObjectMeta.Name == "" { return field.Required(field.NewPath("Name"), "Cluster Name is required (e.g. --name=mycluster.myzone.com)") } { // Must be a dns name - errs := validation.IsDNS1123Subdomain(c.Name) + errs := validation.IsDNS1123Subdomain(c.ObjectMeta.Name) if len(errs) != 0 { return fmt.Errorf("Cluster Name must be a valid DNS name (e.g. --name=mycluster.myzone.com) errors: %s", strings.Join(errs, ", ")) } - if !strings.Contains(c.Name, ".") { + if !strings.Contains(c.ObjectMeta.Name, ".") { // Tolerate if this is a cluster we are importing for upgrade - if c.Annotations[AnnotationNameManagement] != AnnotationValueManagementImported { + if c.ObjectMeta.Annotations[AnnotationNameManagement] != AnnotationValueManagementImported { return fmt.Errorf("Cluster Name must be a fully-qualified DNS name (e.g. --name=mycluster.myzone.com)") } } diff --git a/pkg/client/simple/vfsclientset/cluster.go b/pkg/client/simple/vfsclientset/cluster.go index debb1c4c49b11..0255b5e4b0b43 100644 --- a/pkg/client/simple/vfsclientset/cluster.go +++ b/pkg/client/simple/vfsclientset/cluster.go @@ -90,11 +90,11 @@ func (r *ClusterVFS) Create(c *api.Cluster) (*api.Cluster, error) { return nil, err } - if c.CreationTimestamp.IsZero() { - c.CreationTimestamp = unversioned.NewTime(time.Now().UTC()) + if c.ObjectMeta.CreationTimestamp.IsZero() { + c.ObjectMeta.CreationTimestamp = unversioned.NewTime(time.Now().UTC()) } - clusterName := c.Name + clusterName := c.ObjectMeta.Name if clusterName == "" { return nil, fmt.Errorf("clusterName is required") } @@ -104,7 +104,7 @@ func (r *ClusterVFS) Create(c *api.Cluster) (*api.Cluster, error) { if os.IsExist(err) { return nil, err } - return nil, fmt.Errorf("error writing Cluster %q: %v", c.Name, err) + return nil, fmt.Errorf("error writing Cluster %q: %v", c.ObjectMeta.Name, err) } return c, nil @@ -116,7 +116,7 @@ func (r *ClusterVFS) Update(c *api.Cluster) (*api.Cluster, error) { return nil, err } - clusterName := c.Name + clusterName := c.ObjectMeta.Name if clusterName == "" { return nil, fmt.Errorf("clusterName is required") } @@ -171,11 +171,11 @@ func (r *ClusterVFS) find(clusterName string) (*api.Cluster, error) { c := o.(*api.Cluster) - if c.Name == "" { - c.Name = clusterName + if c.ObjectMeta.Name == "" { + c.ObjectMeta.Name = clusterName } - if c.Name != clusterName { - glog.Warningf("Name of cluster does not match: %q vs %q", c.Name, clusterName) + if c.ObjectMeta.Name != clusterName { + glog.Warningf("Name of cluster does not match: %q vs %q", c.ObjectMeta.Name, clusterName) } // TODO: Split this out into real version updates / schema changes diff --git a/upup/models/cloudup/_aws/master/_master_asg/master_asg.yaml b/upup/models/cloudup/_aws/master/_master_asg/master_asg.yaml index 790b40aa7a878..4f20fbcb6afac 100644 --- a/upup/models/cloudup/_aws/master/_master_asg/master_asg.yaml +++ b/upup/models/cloudup/_aws/master/_master_asg/master_asg.yaml @@ -1,7 +1,7 @@ {{ range $m := Masters }} # ASG for master -launchConfiguration/{{ $m.Name }}.masters.{{ ClusterName }}: +launchConfiguration/{{ $m.ObjectMeta.Name }}.masters.{{ ClusterName }}: sshKey: sshKey/{{ SSHKeyName }} securityGroups: - securityGroup/masters.{{ ClusterName }} @@ -14,14 +14,14 @@ launchConfiguration/{{ $m.Name }}.masters.{{ ClusterName }}: {{ if IsTopologyPrivate }} associatePublicIP: false {{ end }} - userData: resources/nodeup.sh {{ $m.Name }} + userData: resources/nodeup.sh {{ $m.ObjectMeta.Name }} rootVolumeSize: {{ or $m.Spec.RootVolumeSize "20" }} rootVolumeType: {{ or $m.Spec.RootVolumeType "gp2" }} {{ if $m.Spec.MaxPrice }} spotPrice: "{{ $m.Spec.MaxPrice }}" {{ end }} -autoscalingGroup/{{ $m.Name }}.masters.{{ ClusterName }}: +autoscalingGroup/{{ $m.ObjectMeta.Name }}.masters.{{ ClusterName }}: minSize: {{ $m.Spec.MinSize }} maxSize: {{ $m.Spec.MaxSize }} subnets: @@ -34,7 +34,7 @@ autoscalingGroup/{{ $m.Name }}.masters.{{ ClusterName }}: {{ end }} {{ end }} - launchConfiguration: launchConfiguration/{{ $m.Name }}.masters.{{ ClusterName }} + launchConfiguration: launchConfiguration/{{ $m.ObjectMeta.Name }}.masters.{{ ClusterName }} tags: {{ range $k, $v := CloudTags $m }} {{ $k }}: "{{ $v }}" @@ -42,9 +42,9 @@ autoscalingGroup/{{ $m.Name }}.masters.{{ ClusterName }}: {{ if HasTag "_master_lb" }} # Attach ASG to ELB -loadBalancerAttachment/masters.{{ $m.Name }}.{{ ClusterName }}: +loadBalancerAttachment/masters.{{ $m.ObjectMeta.Name }}.{{ ClusterName }}: loadBalancer: loadBalancer/api.{{ ClusterName }} - autoscalingGroup: autoscalingGroup/{{ $m.Name }}.{{ ClusterName }} + autoscalingGroup: autoscalingGroup/{{ $m.ObjectMeta.Name }}.{{ ClusterName }} {{ end }} {{ end }} diff --git a/upup/models/cloudup/_aws/master/_master_single/master_single.yaml b/upup/models/cloudup/_aws/master/_master_single/master_single.yaml index 558918d0d5493..de63998a72da3 100644 --- a/upup/models/cloudup/_aws/master/_master_single/master_single.yaml +++ b/upup/models/cloudup/_aws/master/_master_single/master_single.yaml @@ -29,7 +29,7 @@ instance/master.{{ ClusterName }}: imageId: {{ $.MasterImage }} instanceType: {{ $.MasterMachineType }} associatePublicIP: true - userData: resources/nodeup.sh {{ $.Name }} + userData: resources/nodeup.sh {{ $.ObjectMeta.Name }} blockDeviceMappings: # Map all the ephemeral devices {{ range $d := (MachineTypeInfo $.MasterMachineType).EphemeralDevices }} diff --git a/upup/models/cloudup/_aws/topologies/_topology_private/network.yaml b/upup/models/cloudup/_aws/topologies/_topology_private/network.yaml index c1fe962406f84..e7224a373af4f 100644 --- a/upup/models/cloudup/_aws/topologies/_topology_private/network.yaml +++ b/upup/models/cloudup/_aws/topologies/_topology_private/network.yaml @@ -217,9 +217,9 @@ securityGroupRule/kube-proxy-api-elb: # Attach each master ASG to the ELB # --------------------------------------------------------------- {{ range $m := Masters }} -loadBalancerAttachment/api-elb-attachment.{{ $m.Name }}.{{ ClusterName }}: +loadBalancerAttachment/api-elb-attachment.{{ $m.ObjectMeta.Name }}.{{ ClusterName }}: loadBalancer: loadBalancer/api.{{ ClusterName }} - autoscalingGroup: autoscalingGroup/{{ $m.Name }}.masters.{{ ClusterName }} + autoscalingGroup: autoscalingGroup/{{ $m.ObjectMeta.Name }}.masters.{{ ClusterName }} {{ end }} diff --git a/upup/models/cloudup/_aws/topologies/_topology_private/nodes.yaml b/upup/models/cloudup/_aws/topologies/_topology_private/nodes.yaml index 06787500fda9b..64daf300424e7 100644 --- a/upup/models/cloudup/_aws/topologies/_topology_private/nodes.yaml +++ b/upup/models/cloudup/_aws/topologies/_topology_private/nodes.yaml @@ -46,7 +46,7 @@ securityGroupRule/all-node-to-master: # # The AutoScaleGroup for the Nodes # --------------------------------------------------------------- -launchConfiguration/{{ $ig.Name }}.{{ ClusterName }}: +launchConfiguration/{{ $ig.ObjectMeta.Name }}.{{ ClusterName }}: sshKey: sshKey/{{ SSHKeyName }} securityGroups: - securityGroup/nodes.{{ ClusterName }} @@ -54,14 +54,14 @@ launchConfiguration/{{ $ig.Name }}.{{ ClusterName }}: imageId: {{ $ig.Spec.Image }} instanceType: {{ $ig.Spec.MachineType }} associatePublicIP: false - userData: resources/nodeup.sh {{ $ig.Name }} + userData: resources/nodeup.sh {{ $ig.ObjectMeta.Name }} rootVolumeSize: {{ or $ig.Spec.RootVolumeSize "20" }} rootVolumeType: {{ or $ig.Spec.RootVolumeType "gp2" }} {{ if $ig.Spec.MaxPrice }} spotPrice: "{{ $ig.Spec.MaxPrice }}" {{ end }} -autoscalingGroup/{{ $ig.Name }}.{{ ClusterName }}: - launchConfiguration: launchConfiguration/{{ $ig.Name }}.{{ ClusterName }} +autoscalingGroup/{{ $ig.ObjectMeta.Name }}.{{ ClusterName }}: + launchConfiguration: launchConfiguration/{{ $ig.ObjectMeta.Name }}.{{ ClusterName }} minSize: {{ or $ig.Spec.MinSize 2 }} maxSize: {{ or $ig.Spec.MaxSize 2 }} subnets: diff --git a/upup/models/cloudup/_aws/topologies/_topology_public/nodes.yaml b/upup/models/cloudup/_aws/topologies/_topology_public/nodes.yaml index 9b47edafcb1dc..b4cf9893df029 100644 --- a/upup/models/cloudup/_aws/topologies/_topology_public/nodes.yaml +++ b/upup/models/cloudup/_aws/topologies/_topology_public/nodes.yaml @@ -49,7 +49,7 @@ securityGroupRule/all-node-to-master: {{ range $ig := NodeSets }} # LaunchConfiguration & ASG for nodes -launchConfiguration/{{ $ig.Name }}.{{ ClusterName }}: +launchConfiguration/{{ $ig.ObjectMeta.Name }}.{{ ClusterName }}: sshKey: sshKey/{{ SSHKeyName }} securityGroups: - securityGroup/nodes.{{ ClusterName }} @@ -57,15 +57,15 @@ launchConfiguration/{{ $ig.Name }}.{{ ClusterName }}: imageId: {{ $ig.Spec.Image }} instanceType: {{ $ig.Spec.MachineType }} associatePublicIP: {{ WithDefaultBool $ig.Spec.AssociatePublicIP true }} - userData: resources/nodeup.sh {{ $ig.Name }} + userData: resources/nodeup.sh {{ $ig.ObjectMeta.Name }} rootVolumeSize: {{ or $ig.Spec.RootVolumeSize "20" }} rootVolumeType: {{ or $ig.Spec.RootVolumeType "gp2" }} {{ if $ig.Spec.MaxPrice }} spotPrice: "{{ $ig.Spec.MaxPrice }}" {{ end }} -autoscalingGroup/{{ $ig.Name }}.{{ ClusterName }}: - launchConfiguration: launchConfiguration/{{ $ig.Name }}.{{ ClusterName }} +autoscalingGroup/{{ $ig.ObjectMeta.Name }}.{{ ClusterName }}: + launchConfiguration: launchConfiguration/{{ $ig.ObjectMeta.Name }}.{{ ClusterName }} minSize: {{ or $ig.Spec.MinSize 2 }} maxSize: {{ or $ig.Spec.MaxSize 2 }} subnets: diff --git a/upup/pkg/fi/cloudup/apply_cluster.go b/upup/pkg/fi/cloudup/apply_cluster.go index 51c8ee3b84c2f..5b08980e9b7ce 100644 --- a/upup/pkg/fi/cloudup/apply_cluster.go +++ b/upup/pkg/fi/cloudup/apply_cluster.go @@ -84,7 +84,7 @@ type ApplyClusterCmd struct { func (c *ApplyClusterCmd) Run() error { if c.InstanceGroups == nil { - list, err := c.Clientset.InstanceGroups(c.Cluster.Name).List(k8sapi.ListOptions{}) + list, err := c.Clientset.InstanceGroups(c.Cluster.ObjectMeta.Name).List(k8sapi.ListOptions{}) if err != nil { return err } @@ -320,7 +320,7 @@ func (c *ApplyClusterCmd) Run() error { }) if len(sshPublicKeys) == 0 { - return fmt.Errorf("SSH public key must be specified when running with AWS (create with `kops create secret --name %s sshpublickey admin -i ~/.ssh/id_rsa.pub`)", cluster.Name) + return fmt.Errorf("SSH public key must be specified when running with AWS (create with `kops create secret --name %s sshpublickey admin -i ~/.ssh/id_rsa.pub`)", cluster.ObjectMeta.Name) } if len(sshPublicKeys) != 1 { @@ -335,7 +335,7 @@ func (c *ApplyClusterCmd) Run() error { return "", err } - name := "kubernetes." + cluster.Name + "-" + fingerprint + name := "kubernetes." + cluster.ObjectMeta.Name + "-" + fingerprint return name, nil } } @@ -387,7 +387,7 @@ func (c *ApplyClusterCmd) Run() error { role := ig.Spec.Role if role == "" { - return "", fmt.Errorf("cannot determine role for instance group: %v", ig.Name) + return "", fmt.Errorf("cannot determine role for instance group: %v", ig.ObjectMeta.Name) } nodeUpTags, err := buildNodeupTags(role, tf.cluster, tf.tags) @@ -402,11 +402,11 @@ func (c *ApplyClusterCmd) Run() error { config.Assets = c.Assets - config.ClusterName = cluster.Name + config.ClusterName = cluster.ObjectMeta.Name config.ConfigBase = fi.String(configBase.Path()) - config.InstanceGroupName = ig.Name + config.InstanceGroupName = ig.ObjectMeta.Name var images []*nodeup.Image @@ -550,9 +550,9 @@ func (c *ApplyClusterCmd) Run() error { } for _, g := range c.InstanceGroups { - _, err := c.Clientset.InstanceGroups(c.Cluster.Name).Update(g) + _, err := c.Clientset.InstanceGroups(c.Cluster.ObjectMeta.Name).Update(g) if err != nil { - return fmt.Errorf("error writing InstanceGroup %q to registry: %v", g.Name, err) + return fmt.Errorf("error writing InstanceGroup %q to registry: %v", g.ObjectMeta.Name, err) } } } diff --git a/upup/pkg/fi/cloudup/bootstrapchannelbuilder.go b/upup/pkg/fi/cloudup/bootstrapchannelbuilder.go index c81c105392131..1321c71ad729d 100644 --- a/upup/pkg/fi/cloudup/bootstrapchannelbuilder.go +++ b/upup/pkg/fi/cloudup/bootstrapchannelbuilder.go @@ -39,7 +39,7 @@ func (b *BootstrapChannelBuilder) BuildTasks(l *Loader) error { return fmt.Errorf("error serializing addons yaml: %v", err) } - name := b.cluster.Name + "-addons-bootstrap" + name := b.cluster.ObjectMeta.Name + "-addons-bootstrap" l.tasks[name] = &fitasks.ManagedFile{ Name: fi.String(name), @@ -48,7 +48,7 @@ func (b *BootstrapChannelBuilder) BuildTasks(l *Loader) error { } for key, resource := range manifests { - name := b.cluster.Name + "-addons-" + key + name := b.cluster.ObjectMeta.Name + "-addons-" + key l.tasks[name] = &fitasks.ManagedFile{ Name: fi.String(name), Location: fi.String(resource), diff --git a/upup/pkg/fi/cloudup/populate_cluster_spec.go b/upup/pkg/fi/cloudup/populate_cluster_spec.go index 62d9bfd6ace0d..22da3171758f9 100644 --- a/upup/pkg/fi/cloudup/populate_cluster_spec.go +++ b/upup/pkg/fi/cloudup/populate_cluster_spec.go @@ -228,7 +228,7 @@ func (c *populateClusterSpec) run() error { if err != nil { return fmt.Errorf("error getting DNS for cloud: %v", err) } - dnsZone, err := FindDNSHostedZone(dns, cluster.Name) + dnsZone, err := FindDNSHostedZone(dns, cluster.ObjectMeta.Name) if err != nil { return fmt.Errorf("Error determining default DNS zone; please specify --dns-zone: %v", err) } diff --git a/upup/pkg/fi/cloudup/populate_instancegroup_spec.go b/upup/pkg/fi/cloudup/populate_instancegroup_spec.go index 766cc66bae107..ab6e9126ac011 100644 --- a/upup/pkg/fi/cloudup/populate_instancegroup_spec.go +++ b/upup/pkg/fi/cloudup/populate_instancegroup_spec.go @@ -87,7 +87,7 @@ func PopulateInstanceGroupSpec(cluster *api.Cluster, input *api.InstanceGroup, c if ig.IsMaster() { if len(ig.Spec.Zones) == 0 { - return nil, fmt.Errorf("Master InstanceGroup %s did not specify any Zones", ig.Name) + return nil, fmt.Errorf("Master InstanceGroup %s did not specify any Zones", ig.ObjectMeta.Name) } } else { if len(ig.Spec.Zones) == 0 { diff --git a/upup/pkg/fi/cloudup/template_functions.go b/upup/pkg/fi/cloudup/template_functions.go index 27817fd7cf454..c998704f75c44 100644 --- a/upup/pkg/fi/cloudup/template_functions.go +++ b/upup/pkg/fi/cloudup/template_functions.go @@ -117,7 +117,7 @@ func (tf *TemplateFunctions) AddTo(dest template.FuncMap) { } dest["ClusterName"] = func() string { - return tf.cluster.Name + return tf.cluster.ObjectMeta.Name } dest["HasTag"] = tf.HasTag @@ -231,7 +231,7 @@ func (tf *TemplateFunctions) GetBastionIdleTimeout() (int, error) { // Will never return a string longer than 32 chars func (tf *TemplateFunctions) GetELBName32(prefix string) (string, error) { var returnString string - c := tf.cluster.Name + c := tf.cluster.ObjectMeta.Name s := strings.Split(c, ".") if len(s) > 0 { returnString = fmt.Sprintf("%s-%s", prefix, s[0]) @@ -362,7 +362,7 @@ func (tf *TemplateFunctions) CloudTags(ig *api.InstanceGroup) (map[string]string // GetInstanceGroup returns the instance group with the specified name func (tf *TemplateFunctions) GetInstanceGroup(name string) (*api.InstanceGroup, error) { for _, ig := range tf.instanceGroups { - if ig.Name == name { + if ig.ObjectMeta.Name == name { return ig, nil } } diff --git a/upup/pkg/fi/cloudup/utils.go b/upup/pkg/fi/cloudup/utils.go index db656e267ae24..a94175daf065d 100644 --- a/upup/pkg/fi/cloudup/utils.go +++ b/upup/pkg/fi/cloudup/utils.go @@ -76,7 +76,7 @@ func BuildCloud(cluster *api.Cluster) (fi.Cloud, error) { return nil, err } - cloudTags := map[string]string{awsup.TagClusterName: cluster.Name} + cloudTags := map[string]string{awsup.TagClusterName: cluster.ObjectMeta.Name} awsCloud, err := awsup.NewAWSCloud(region, cloudTags) if err != nil { diff --git a/upup/pkg/fi/nodeup/template_functions.go b/upup/pkg/fi/nodeup/template_functions.go index 2ee165404b80b..032533479b19c 100644 --- a/upup/pkg/fi/nodeup/template_functions.go +++ b/upup/pkg/fi/nodeup/template_functions.go @@ -94,7 +94,7 @@ func newTemplateFunctions(nodeupConfig *NodeUpConfig, cluster *api.Cluster, inst // TODO: Remove this once we have a stable release glog.Warningf("Building a synthetic instance group") instanceGroup = &api.InstanceGroup{} - instanceGroup.Name = "synthetic" + instanceGroup.ObjectMeta.Name = "synthetic" if t.IsMaster() { instanceGroup.Spec.Role = api.InstanceGroupRoleMaster } else { @@ -150,7 +150,7 @@ func (t *templateFunctions) populate(dest template.FuncMap) { } dest["ClusterName"] = func() string { - return t.cluster.Name + return t.cluster.ObjectMeta.Name } dest["ProtokubeImage"] = t.ProtokubeImage diff --git a/upup/pkg/kutil/convert_kubeup_cluster.go b/upup/pkg/kutil/convert_kubeup_cluster.go index b151fe18035f1..43deac8f349bd 100644 --- a/upup/pkg/kutil/convert_kubeup_cluster.go +++ b/upup/pkg/kutil/convert_kubeup_cluster.go @@ -72,7 +72,7 @@ func (x *ConvertKubeupCluster) Upgrade() error { newTags["KubernetesCluster"] = newClusterName // Build completed cluster (force errors asap) - cluster.Name = newClusterName + cluster.ObjectMeta.Name = newClusterName newConfigBase, err := x.Clientset.Clusters().(*vfsclientset.ClusterVFS).ConfigBase(newClusterName) if err != nil { @@ -95,9 +95,9 @@ func (x *ConvertKubeupCluster) Upgrade() error { return fmt.Errorf("error populating cluster defaults: %v", err) } - if cluster.Annotations != nil { + if cluster.ObjectMeta.Annotations != nil { // Remove the management annotation for the new cluster - delete(cluster.Annotations, api.AnnotationNameManagement) + delete(cluster.ObjectMeta.Annotations, api.AnnotationNameManagement) } fullCluster, err := cloudup.PopulateClusterSpec(cluster) diff --git a/upup/pkg/kutil/delete_instancegroup.go b/upup/pkg/kutil/delete_instancegroup.go index 8e98ca7db63fa..715d29106513e 100644 --- a/upup/pkg/kutil/delete_instancegroup.go +++ b/upup/pkg/kutil/delete_instancegroup.go @@ -32,7 +32,7 @@ type DeleteInstanceGroup struct { func (c *DeleteInstanceGroup) DeleteInstanceGroup(group *api.InstanceGroup) error { groups, err := FindCloudInstanceGroups(c.Cloud, c.Cluster, []*api.InstanceGroup{group}, false, nil) - cig := groups[group.Name] + cig := groups[group.ObjectMeta.Name] if cig == nil { return fmt.Errorf("InstanceGroup not found in cloud") } @@ -45,7 +45,7 @@ func (c *DeleteInstanceGroup) DeleteInstanceGroup(group *api.InstanceGroup) erro return fmt.Errorf("error deleting cloud resources for InstanceGroup: %v", err) } - err = c.Clientset.InstanceGroups(c.Cluster.Name).Delete(group.Name, nil) + err = c.Clientset.InstanceGroups(c.Cluster.ObjectMeta.Name).Delete(group.ObjectMeta.Name, nil) if err != nil { return err } diff --git a/upup/pkg/kutil/import_cluster.go b/upup/pkg/kutil/import_cluster.go index 263a0c5d23a42..f2b1a0cb3ac34 100644 --- a/upup/pkg/kutil/import_cluster.go +++ b/upup/pkg/kutil/import_cluster.go @@ -52,13 +52,13 @@ func (x *ImportCluster) ImportAWSCluster() error { var instanceGroups []*api.InstanceGroup cluster := &api.Cluster{} - cluster.Annotations = make(map[string]string) + cluster.ObjectMeta.Annotations = make(map[string]string) // This annotation relaxes some validation (e.g. cluster name as full-dns name) - cluster.Annotations[api.AnnotationNameManagement] = api.AnnotationValueManagementImported + cluster.ObjectMeta.Annotations[api.AnnotationNameManagement] = api.AnnotationValueManagementImported cluster.Spec.CloudProvider = string(fi.CloudProviderAWS) - cluster.Name = clusterName + cluster.ObjectMeta.Name = clusterName cluster.Spec.KubeControllerManager = &api.KubeControllerManagerConfig{} @@ -185,7 +185,7 @@ func (x *ImportCluster) ImportAWSCluster() error { return fmt.Errorf("cannot find zone %q for master. Please report this issue", aws.StringValue(masterInstance.Placement.AvailabilityZone)) } masterGroup.Spec.Zones = []string{masterZone.Name} - masterGroup.Name = "master-" + masterZone.Name + masterGroup.ObjectMeta.Name = "master-" + masterZone.Name userData, err := GetInstanceUserData(awsCloud, aws.StringValue(masterInstance.InstanceId)) if err != nil { @@ -261,7 +261,7 @@ func (x *ImportCluster) ImportAWSCluster() error { nodeGroup := &api.InstanceGroup{} nodeGroup.Spec.Role = api.InstanceGroupRoleNode - nodeGroup.Name = "nodes" + nodeGroup.ObjectMeta.Name = "nodes" for _, zone := range zones { nodeGroup.Spec.Zones = append(nodeGroup.Spec.Zones, zone.Name) } diff --git a/upup/pkg/kutil/rollingupdate_cluster.go b/upup/pkg/kutil/rollingupdate_cluster.go index d0711c3774aea..fe46cbbc05465 100644 --- a/upup/pkg/kutil/rollingupdate_cluster.go +++ b/upup/pkg/kutil/rollingupdate_cluster.go @@ -67,9 +67,9 @@ func FindCloudInstanceGroups(cloud fi.Cloud, cluster *api.Cluster, instancegroup var asgName string switch g.Spec.Role { case api.InstanceGroupRoleMaster: - asgName = g.Name + ".masters." + cluster.Name + asgName = g.ObjectMeta.Name + ".masters." + cluster.ObjectMeta.Name case api.InstanceGroupRoleNode: - asgName = g.Name + "." + cluster.Name + asgName = g.ObjectMeta.Name + "." + cluster.ObjectMeta.Name default: glog.Warningf("Ignoring InstanceGroup of unknown role %q", g.Spec.Role) continue @@ -89,7 +89,7 @@ func FindCloudInstanceGroups(cloud fi.Cloud, cluster *api.Cluster, instancegroup continue } group := buildCloudInstanceGroup(instancegroup, asg, nodeMap) - groups[instancegroup.Name] = group + groups[instancegroup.ObjectMeta.Name] = group } return groups, nil @@ -112,7 +112,7 @@ func (c *RollingUpdateCluster) RollingUpdate(groups map[string]*CloudInstanceGro case api.InstanceGroupRoleMaster: masterGroups[k] = group default: - return fmt.Errorf("unknown group type for group %q", group.InstanceGroup.Name) + return fmt.Errorf("unknown group type for group %q", group.InstanceGroup.ObjectMeta.Name) } }