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

Add security settings base on master warn check in kube-bench cis-1.6 #42

Merged
merged 2 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,14 @@ kops_default_kubelet:
anonymousAuth: false
authenticationTokenWebhook: true
authorizationMode: Webhook
tlsCipherSuites:
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
kops_default_kubeControllerManager:
enableProfiling: false
terminatedPodGCThreshold: 12500
tlsCipherSuites:
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
kops_default_kubeScheduler:
enableProfiling: false
43 changes: 43 additions & 0 deletions tasks/asserts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@
{{ kops_default_kubelet }}
{%- endif -%}

- name: "({{ cluster.name }}) ensure kops_kubelet.tlsCipherSuites is list(string)"
assert:
that:
- item.tlsCipherSuites is defined
- item.tlsCipherSuites | type_debug == "list"
msg: "kops_kubelet.tlsCipherSuites should be list(string)"
with_items:
- >-
{%- if cluster.kops_kubelet is defined and 'tlsCipherSuites' in cluster.kops_kubelet -%}
{{ cluster.kops_kubelet }}
{%- else -%}
{{ kops_default_kubelet }}
{%- endif -%}

- name: "({{ cluster.name }}) ensure kubeControllerManager.enableProfiling is boolean"
assert:
that:
Expand All @@ -193,6 +207,35 @@
{{ kops_default_kubeControllerManager }}
{%- endif -%}

- name: "({{ cluster.name }}) ensure kube_controller_manager.terminatedPodGCThreshold is larger or equal to 0"
assert:
that:
- item.terminatedPodGCThreshold is defined
- item.terminatedPodGCThreshold >= 0
msg: "kube_controller_manager.terminatedPodGCThreshold should >= 0"
with_items:
- >-
{%- if cluster.kube_controller_manager is defined and
'terminatedPodGCThreshold' in cluster.kube_controller_manager -%}
{{ cluster.kube_controller_manager }}
{%- else -%}
{{ kops_default_kubeControllerManager }}
{%- endif -%}

- name: "({{ cluster.name }}) ensure kube_controller_manager.tlsCipherSuites is list(string)"
assert:
that:
- item.tlsCipherSuites is defined
- item.tlsCipherSuites | type_debug == "list"
msg: "kube_controller_manager.tlsCipherSuites should be list(string)"
with_items:
- >-
{%- if cluster.kube_controller_manager is defined and 'tlsCipherSuites' in cluster.kube_controller_manager -%}
{{ cluster.kube_controller_manager }}
{%- else -%}
{{ kops_default_kubeControllerManager }}
{%- endif -%}

- name: "({{ cluster.name }}) ensure kubeScheduler.enableProfiling is boolean"
assert:
that:
Expand Down
11 changes: 11 additions & 0 deletions templates/cluster.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,19 @@ spec:
anonymousAuth: {{ cluster.kops_kubelet.anonymousAuth | default(kops_default_kubelet.anonymousAuth) }}
authenticationTokenWebhook: {{ cluster.kops_kubelet.authenticationTokenWebhook | default(kops_default_kubelet.authenticationTokenWebhook) }}
authorizationMode: {{ cluster.kops_kubelet.authorizationMode | default(kops_default_kubelet.authorizationMode) }}
{% if 'kops_kubelet' in cluster and 'tlsCipherSuites' in cluster.kops_kubelet %}
tlsCipherSuites:
{{ cluster.kops_kubelet.tlsCipherSuites | to_nice_yaml(indent=2) | indent(width=6, first=True) -}}
{% endif %}
kubeControllerManager:
enableProfiling: {{ cluster.kops_kubeControllerManager.enableProfiling | default(kops_default_kubeControllerManager.enableProfiling) }}
{% if cluster.kube_controller_manager.terminatedPodGCThreshold is defined %}
terminatedPodGCThreshold: {{ cluster.kube_controller_manager.terminatedPodGCThreshold }}
{% endif %}
{% if 'kube_controller_manager' in cluster and 'tlsCipherSuites' in cluster.kube_controller_manager %}
tlsCipherSuites:
{{ cluster.kube_controller_manager.tlsCipherSuites | to_nice_yaml(indent=2) | indent(width=6, first=True) -}}
{% endif %}
kubeScheduler:
enableProfiling: {{ cluster.kops_kubeScheduler.enableProfiling | default(kops_default_kubeScheduler.enableProfiling) }}
api:
Expand Down