Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change default args to conform with cis #493

Closed
wants to merge 10 commits into from
Closed
3 changes: 3 additions & 0 deletions src/k8s/pkg/k8sd/setup/kube_apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func KubeAPIServer(snap snap.Snap, serviceCIDR string, authWebhookURL string, en

args := map[string]string{
"--allow-privileged": "true",
"--anonymous-auth": "false",
"--authentication-token-webhook-config-file": authTokenWebhookConfigFile,
"--authorization-mode": authorizationMode,
"--client-ca-file": path.Join(snap.KubernetesPKIDir(), "client-ca.crt"),
Expand All @@ -73,6 +74,8 @@ func KubeAPIServer(snap snap.Snap, serviceCIDR string, authWebhookURL string, en
"--kubelet-client-certificate": path.Join(snap.KubernetesPKIDir(), "apiserver-kubelet-client.crt"),
"--kubelet-client-key": path.Join(snap.KubernetesPKIDir(), "apiserver-kubelet-client.key"),
"--kubelet-preferred-address-types": "InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP",
"--profiling": "false",
"--requests-timeout": "300s",
"--secure-port": "6443",
"--service-account-issuer": "https://kubernetes.default.svc",
"--service-account-key-file": path.Join(snap.KubernetesPKIDir(), "serviceaccount.key"),
Expand Down
45 changes: 27 additions & 18 deletions src/k8s/pkg/k8sd/setup/kube_apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,25 @@ func TestKubeAPIServer(t *testing.T) {
expectedVal string
}{
{key: "--allow-privileged", expectedVal: "true"},
{key: "--anonymous-auth", expectedVal: "false"},
{key: "--authentication-token-webhook-config-file", expectedVal: path.Join(s.Mock.ServiceExtraConfigDir, "auth-token-webhook.conf")},
{key: "--authorization-mode", expectedVal: "Node,RBAC"},
{key: "--client-ca-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "client-ca.crt")},
{key: "--enable-admission-plugins", expectedVal: "NodeRestriction"},
{key: "--etcd-servers", expectedVal: fmt.Sprintf("unix://%s", path.Join(s.Mock.K8sDqliteStateDir, "k8s-dqlite.sock"))},
{key: "--kubelet-certificate-authority", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "ca.crt")},
{key: "--kubelet-client-certificate", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "apiserver-kubelet-client.crt")},
{key: "--kubelet-client-key", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "apiserver-kubelet-client.key")},
{key: "--kubelet-preferred-address-types", expectedVal: "InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP"},
{key: "--profiling", expectedVal: "false"},
{key: "--proxy-client-cert-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "front-proxy-client.crt")},
{key: "--proxy-client-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "front-proxy-client.key")},
{key: "--requestheader-allowed-names", expectedVal: "front-proxy-client"},
{key: "--requestheader-client-ca-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "front-proxy-ca.crt")},
{key: "--requestheader-extra-headers-prefix", expectedVal: "X-Remote-Extra-"},
{key: "--requestheader-group-headers", expectedVal: "X-Remote-Group"},
{key: "--requestheader-username-headers", expectedVal: "X-Remote-User"},
{key: "--requests-timeout", expectedVal: "300s"},
{key: "--secure-port", expectedVal: "6443"},
{key: "--service-account-issuer", expectedVal: "https://kubernetes.default.svc"},
{key: "--service-account-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "serviceaccount.key")},
Expand All @@ -60,14 +71,6 @@ func TestKubeAPIServer(t *testing.T) {
{key: "--tls-cert-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "apiserver.crt")},
{key: "--tls-cipher-suites", expectedVal: apiserverTLSCipherSuites},
{key: "--tls-private-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "apiserver.key")},
{key: "--etcd-servers", expectedVal: fmt.Sprintf("unix://%s", path.Join(s.Mock.K8sDqliteStateDir, "k8s-dqlite.sock"))},
{key: "--requestheader-client-ca-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "front-proxy-ca.crt")},
{key: "--requestheader-allowed-names", expectedVal: "front-proxy-client"},
{key: "--requestheader-extra-headers-prefix", expectedVal: "X-Remote-Extra-"},
{key: "--requestheader-group-headers", expectedVal: "X-Remote-Group"},
{key: "--requestheader-username-headers", expectedVal: "X-Remote-User"},
{key: "--proxy-client-cert-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "front-proxy-client.crt")},
{key: "--proxy-client-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "front-proxy-client.key")},
}
for _, tc := range tests {
t.Run(tc.key, func(t *testing.T) {
Expand Down Expand Up @@ -99,14 +102,18 @@ func TestKubeAPIServer(t *testing.T) {
expectedVal string
}{
{key: "--allow-privileged", expectedVal: "true"},
{key: "--anonymous-auth", expectedVal: "false"},
{key: "--authentication-token-webhook-config-file", expectedVal: path.Join(s.Mock.ServiceExtraConfigDir, "auth-token-webhook.conf")},
{key: "--authorization-mode", expectedVal: "Node,RBAC"},
{key: "--client-ca-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "client-ca.crt")},
{key: "--enable-admission-plugins", expectedVal: "NodeRestriction"},
{key: "--etcd-servers", expectedVal: fmt.Sprintf("unix://%s", path.Join(s.Mock.K8sDqliteStateDir, "k8s-dqlite.sock"))},
{key: "--kubelet-certificate-authority", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "ca.crt")},
{key: "--kubelet-client-certificate", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "apiserver-kubelet-client.crt")},
{key: "--kubelet-client-key", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "apiserver-kubelet-client.key")},
{key: "--kubelet-preferred-address-types", expectedVal: "InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP"},
{key: "--profiling", expectedVal: "false"},
{key: "--requests-timeout", expectedVal: "300s"},
{key: "--secure-port", expectedVal: "6443"},
{key: "--service-account-issuer", expectedVal: "https://kubernetes.default.svc"},
{key: "--service-account-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "serviceaccount.key")},
Expand All @@ -115,7 +122,6 @@ func TestKubeAPIServer(t *testing.T) {
{key: "--tls-cert-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "apiserver.crt")},
{key: "--tls-cipher-suites", expectedVal: apiserverTLSCipherSuites},
{key: "--tls-private-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "apiserver.key")},
{key: "--etcd-servers", expectedVal: fmt.Sprintf("unix://%s", path.Join(s.Mock.K8sDqliteStateDir, "k8s-dqlite.sock"))},
}
for _, tc := range tests {
t.Run(tc.key, func(t *testing.T) {
Expand Down Expand Up @@ -151,14 +157,26 @@ func TestKubeAPIServer(t *testing.T) {
key string
expectedVal string
}{
{key: "--anonymous-auth", expectedVal: "false"},
{key: "--authentication-token-webhook-config-file", expectedVal: path.Join(s.Mock.ServiceExtraConfigDir, "auth-token-webhook.conf")},
{key: "--authorization-mode", expectedVal: "Node,RBAC"},
{key: "--client-ca-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "client-ca.crt")},
{key: "--enable-admission-plugins", expectedVal: "NodeRestriction"},
{key: "--etcd-servers", expectedVal: fmt.Sprintf("unix://%s", path.Join(s.Mock.K8sDqliteStateDir, "k8s-dqlite.sock"))},
{key: "--kubelet-certificate-authority", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "ca.crt")},
{key: "--kubelet-client-certificate", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "apiserver-kubelet-client.crt")},
{key: "--kubelet-client-key", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "apiserver-kubelet-client.key")},
{key: "--kubelet-preferred-address-types", expectedVal: "InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP"},
{key: "--my-extra-arg", expectedVal: "my-extra-val"},
{key: "--profiling", expectedVal: "false"},
{key: "--proxy-client-cert-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "front-proxy-client.crt")},
{key: "--proxy-client-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "front-proxy-client.key")},
{key: "--requestheader-allowed-names", expectedVal: "front-proxy-client"},
{key: "--requestheader-client-ca-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "front-proxy-ca.crt")},
{key: "--requestheader-extra-headers-prefix", expectedVal: "X-Remote-Extra-"},
{key: "--requestheader-group-headers", expectedVal: "X-Remote-Group"},
{key: "--requestheader-username-headers", expectedVal: "X-Remote-User"},
{key: "--requests-timeout", expectedVal: "300s"},
{key: "--secure-port", expectedVal: "1337"},
{key: "--service-account-issuer", expectedVal: "https://kubernetes.default.svc"},
{key: "--service-account-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "serviceaccount.key")},
Expand All @@ -167,15 +185,6 @@ func TestKubeAPIServer(t *testing.T) {
{key: "--tls-cert-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "apiserver.crt")},
{key: "--tls-cipher-suites", expectedVal: apiserverTLSCipherSuites},
{key: "--tls-private-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "apiserver.key")},
{key: "--etcd-servers", expectedVal: fmt.Sprintf("unix://%s", path.Join(s.Mock.K8sDqliteStateDir, "k8s-dqlite.sock"))},
{key: "--requestheader-client-ca-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "front-proxy-ca.crt")},
{key: "--requestheader-allowed-names", expectedVal: "front-proxy-client"},
{key: "--requestheader-extra-headers-prefix", expectedVal: "X-Remote-Extra-"},
{key: "--requestheader-group-headers", expectedVal: "X-Remote-Group"},
{key: "--requestheader-username-headers", expectedVal: "X-Remote-User"},
{key: "--proxy-client-cert-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "front-proxy-client.crt")},
{key: "--proxy-client-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "front-proxy-client.key")},
{key: "--my-extra-arg", expectedVal: "my-extra-val"},
}
for _, tc := range tests {
t.Run(tc.key, func(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions src/k8s/pkg/k8sd/setup/kube_controller_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func KubeControllerManager(snap snap.Snap, extraArgs map[string]*string) error {
"--root-ca-file": path.Join(snap.KubernetesPKIDir(), "ca.crt"),
"--service-account-private-key-file": path.Join(snap.KubernetesPKIDir(), "serviceaccount.key"),
"--use-service-account-credentials": "true",
"--terminated-pod-gc-threshold": "12500",
}
// enable cluster-signing if certificates are available
if _, err := os.Stat(path.Join(snap.KubernetesPKIDir(), "ca.key")); err == nil {
Expand Down
7 changes: 5 additions & 2 deletions src/k8s/pkg/k8sd/setup/kube_controller_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ func TestKubeControllerManager(t *testing.T) {
}{
{key: "--authentication-kubeconfig", expectedVal: path.Join(s.Mock.KubernetesConfigDir, "controller.conf")},
{key: "--authorization-kubeconfig", expectedVal: path.Join(s.Mock.KubernetesConfigDir, "controller.conf")},
{key: "--cluster-signing-cert-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "ca.crt")},
{key: "--cluster-signing-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "ca.key")},
{key: "--kubeconfig", expectedVal: path.Join(s.Mock.KubernetesConfigDir, "controller.conf")},
{key: "--leader-elect-lease-duration", expectedVal: "30s"},
{key: "--leader-elect-renew-deadline", expectedVal: "15s"},
{key: "--profiling", expectedVal: "false"},
{key: "--root-ca-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "ca.crt")},
{key: "--service-account-private-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "serviceaccount.key")},
{key: "--terminated-pod-gc-threshold", expectedVal: "12500"},
{key: "--use-service-account-credentials", expectedVal: "true"},
{key: "--cluster-signing-cert-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "ca.crt")},
{key: "--cluster-signing-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "ca.key")},
}
for _, tc := range tests {
t.Run(tc.key, func(t *testing.T) {
Expand Down Expand Up @@ -94,6 +95,7 @@ func TestKubeControllerManager(t *testing.T) {
{key: "--root-ca-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "ca.crt")},
{key: "--service-account-private-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "serviceaccount.key")},
{key: "--use-service-account-credentials", expectedVal: "true"},
{key: "--terminated-pod-gc-threshold", expectedVal: "12500"},
}
for _, tc := range tests {
t.Run(tc.key, func(t *testing.T) {
Expand Down Expand Up @@ -149,6 +151,7 @@ func TestKubeControllerManager(t *testing.T) {
{key: "--cluster-signing-cert-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "ca.crt")},
{key: "--cluster-signing-key-file", expectedVal: path.Join(s.Mock.KubernetesPKIDir, "ca.key")},
{key: "--my-extra-arg", expectedVal: "my-extra-val"},
{key: "--terminated-pod-gc-threshold", expectedVal: "12500"},
}
for _, tc := range tests {
t.Run(tc.key, func(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion src/k8s/pkg/k8sd/setup/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func kubelet(snap snap.Snap, hostname string, nodeIP net.IP, clusterDNS string,
args := map[string]string{
"--anonymous-auth": "false",
"--authentication-token-webhook": "true",
"--cert-dir": snap.KubernetesPKIDir(),
"--tls-cert-file": path.Join(snap.KubernetesPKIDir(), "kubelet.crt"),
"--tls-private-key": path.Join(snap.KubernetesPKIDir(), "kubelet.key"),
"--client-ca-file": path.Join(snap.KubernetesPKIDir(), "client-ca.crt"),
"--container-runtime-endpoint": path.Join(snap.ContainerdSocketDir(), "containerd.sock"),
"--containerd": path.Join(snap.ContainerdSocketDir(), "containerd.sock"),
Expand Down
Loading
Loading