mirror of https://github.com/kubernetes/kops.git
				
				
				
			Merge pull request #6619 from phedoreanu/set_cluster_spec_kubelet
add support to set cluster spec.kubelet
This commit is contained in:
		
						commit
						79c4c19680
					
				| 
						 | 
				
			
			@ -35,5 +35,8 @@ go_test(
 | 
			
		|||
    name = "go_default_test",
 | 
			
		||||
    srcs = ["set_cluster_test.go"],
 | 
			
		||||
    embed = [":go_default_library"],
 | 
			
		||||
    deps = ["//pkg/apis/kops:go_default_library"],
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//pkg/apis/kops:go_default_library",
 | 
			
		||||
        "//upup/pkg/fi:go_default_library",
 | 
			
		||||
    ],
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -81,6 +81,14 @@ func SetClusterFields(fields []string, cluster *api.Cluster, instanceGroups []*a
 | 
			
		|||
 | 
			
		||||
		// For now we have hard-code the values we want to support; we'll get test coverage and then do this properly...
 | 
			
		||||
		switch kv[0] {
 | 
			
		||||
		case "spec.kubelet.authorizationMode":
 | 
			
		||||
			cluster.Spec.Kubelet.AuthorizationMode = kv[1]
 | 
			
		||||
		case "spec.kubelet.authenticationTokenWebhook":
 | 
			
		||||
			v, err := strconv.ParseBool(kv[1])
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return fmt.Errorf("unknown boolean value: %q", kv[1])
 | 
			
		||||
			}
 | 
			
		||||
			cluster.Spec.Kubelet.AuthenticationTokenWebhook = &v
 | 
			
		||||
		case "cluster.spec.nodePortAccess":
 | 
			
		||||
			cluster.Spec.NodePortAccess = append(cluster.Spec.NodePortAccess, kv[1])
 | 
			
		||||
		case "spec.kubernetesVersion":
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@ import (
 | 
			
		|||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"k8s.io/kops/pkg/apis/kops"
 | 
			
		||||
	"k8s.io/kops/upup/pkg/fi"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestSetClusterFields(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			@ -32,9 +33,22 @@ func TestSetClusterFields(t *testing.T) {
 | 
			
		|||
		{
 | 
			
		||||
			Fields: []string{
 | 
			
		||||
				"spec.kubernetesVersion=1.8.2",
 | 
			
		||||
				"spec.kubelet.authorizationMode=Webhook",
 | 
			
		||||
				"spec.kubelet.authenticationTokenWebhook=true",
 | 
			
		||||
			},
 | 
			
		||||
			Input: kops.Cluster{
 | 
			
		||||
				Spec: kops.ClusterSpec{
 | 
			
		||||
					Kubelet: &kops.KubeletConfigSpec{},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			Output: kops.Cluster{
 | 
			
		||||
				Spec: kops.ClusterSpec{KubernetesVersion: "1.8.2"},
 | 
			
		||||
				Spec: kops.ClusterSpec{
 | 
			
		||||
					KubernetesVersion: "1.8.2",
 | 
			
		||||
					Kubelet: &kops.KubeletConfigSpec{
 | 
			
		||||
						AuthorizationMode:          "Webhook",
 | 
			
		||||
						AuthenticationTokenWebhook: fi.Bool(true),
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue