Skip to content

Commit

Permalink
fix(adapter): Reduce k8tls adapter permissions (#249)
Browse files Browse the repository at this point in the history
Signed-off-by: Anurag Rajawat <[email protected]>
  • Loading branch information
anurag-rajawat authored Oct 1, 2024
1 parent e445f8e commit cddd9e9
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 335 deletions.
159 changes: 131 additions & 28 deletions deployments/nimbus-k8tls/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,140 @@ kind: ConfigMap
metadata:
name: fluent-bit-config
namespace: {{ include "nimbus-k8tls.fullname" . }}-env
labels:
{{- include "nimbus-k8tls.labels" . | nindent 4 }}
data:
fluent-bit.conf: |
[SERVICE]
Flush 1
Log_Level info
Parsers_File parsers.conf
[SERVICE]
Flush 1
Log_Level info
Parsers_File parsers.conf
[INPUT]
Name tail
Path /tmp/compact_report.json
Parser json
Tag json.data
DB /tmp/compact_report.db
Read_from_Head true
Exit_On_Eof true
[INPUT]
Name tail
Path /tmp/compact_report.json
Parser json
Tag json.data
DB /tmp/compact_report.db
Read_from_Head true
Exit_On_Eof true
{{- if .Values.output.elasticsearch.enabled }}
[OUTPUT]
Name es
Match *
Host {{ .Values.output.elasticsearch.host }}
Port {{ .Values.output.elasticsearch.port }}
Index {{ .Values.output.elasticsearch.index }}
HTTP_User {{ .Values.output.elasticsearch.user }}
HTTP_Passwd ${ES_PASSWORD}
tls On
tls.verify Off
Suppress_Type_Name On
Replace_Dots On
[OUTPUT]
Name es
Match *
Host {{ .Values.output.elasticsearch.host }}
Port {{ .Values.output.elasticsearch.port }}
Index {{ .Values.output.elasticsearch.index }}
HTTP_User {{ .Values.output.elasticsearch.user }}
HTTP_Passwd ${ES_PASSWORD}
tls On
tls.verify Off
Suppress_Type_Name On
Replace_Dots On
{{- end }}
[OUTPUT]
Name stdout
Match *
[OUTPUT]
Name stdout
Match *
---
apiVersion: v1
kind: ConfigMap
metadata:
name: fips-config
namespace: {{ include "nimbus-k8tls.fullname" . }}-env
labels:
{{- include "nimbus-k8tls.labels" . | nindent 4 }}
data:
fips-140-3.json: |2-
{
"TLS_versions": [
{
"TLS_version": "TLSv1.0_1.1",
"cipher_suites": [
{
"cipher_suite": "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA"
},
{
"cipher_suite": "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA"
},
{
"cipher_suite": "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA"
},
{
"cipher_suite": "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA"
}
]
},
{
"TLS_version": "TLSv1.2",
"cipher_suites": [
{
"cipher_suite": "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA"
},
{
"cipher_suite": "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA"
},
{
"cipher_suite": "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA"
},
{
"cipher_suite": "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA"
},
{
"cipher_suite": "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
},
{
"cipher_suite": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
},
{
"cipher_suite": "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
},
{
"cipher_suite": "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"
},
{
"cipher_suite": "TLS_ECDHE_ECDSA_WITH_AES_256_CCM"
},
{
"cipher_suite": "TLS_ECDHE_ECDSA_WITH_AES_128_CCM"
},
{
"cipher_suite": "TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8"
},
{
"cipher_suite": "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8"
},
{
"cipher_suite": "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384"
},
{
"cipher_suite": "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"
},
{
"cipher_suite": "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384"
},
{
"cipher_suite": "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256"
}
]
},
{
"TLS_version": "TLSv1.3",
"cipher_suites": [
{
"cipher_suite": "TLS_AES_256_GCM_SHA384"
},
{
"cipher_suite": "TLS_AES_128_GCM_SHA256"
},
{
"cipher_suite": "TLS_AES_128_CCM_SHA256"
},
{
"cipher_suite": "TLS_AES_128_CCM_8_SHA256"
}
]
}
]
}
2 changes: 1 addition & 1 deletion deployments/nimbus-k8tls/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- if .Values.output.elasticsearch.enabled }}
env:
- name: TTLSECONDSAFTERFINISHED
value: "{{ .Values.output.elasticsearch.ttlsecondsafterfinished }}"
{{- end }}
Expand Down
14 changes: 14 additions & 0 deletions deployments/nimbus-k8tls/templates/k8tls-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: k8tls
labels:
{{- include "nimbus-k8tls.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- services
verbs:
- get
- list
4 changes: 3 additions & 1 deletion deployments/nimbus-k8tls/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: {{ include "nimbus-k8tls.fullname" . }}-env
name: {{ include "nimbus-k8tls.fullname" . }}-env
labels:
{{- include "nimbus-k8tls.labels" . | nindent 4 }}
110 changes: 50 additions & 60 deletions deployments/nimbus-k8tls/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,56 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: nimbus-k8tls-clusterrole
name: nimbus-k8tls
labels:
{{- include "nimbus-k8tls.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- configmaps
- namespaces
- serviceaccounts
verbs:
- create
- delete
- get
- update
- apiGroups:
- ""
resources:
- services
verbs:
- get
- list
- apiGroups:
- batch
resources:
- cronjobs
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- intent.security.nimbus.com
resources:
- clusternimbuspolicies
verbs:
- get
- list
- watch
- apiGroups:
- intent.security.nimbus.com
resources:
- clusternimbuspolicies/status
verbs:
- get
- patch
- update
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterrolebindings
- clusterroles
verbs:
- create
- delete
- get
- update
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- delete
- get
- update
- apiGroups:
- ""
resources:
- namespaces
- serviceaccounts
verbs:
- get
- apiGroups:
- batch
resources:
- cronjobs
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- intent.security.nimbus.com
resources:
- clusternimbuspolicies
verbs:
- get
- list
- watch
- apiGroups:
- intent.security.nimbus.com
resources:
- clusternimbuspolicies/status
verbs:
- get
- patch
- update
{{- if .Values.output.elasticsearch.enabled }}
- apiGroups: [""]
resources: ["secrets"]
resourceNames: ["elasticsearch-password"]
verbs: ["get"]
- apiGroups: [ "" ]
resources: [ "secrets" ]
resourceNames: [ "elasticsearch-password" ]
verbs: [ "get" ]
{{- end }}
21 changes: 19 additions & 2 deletions deployments/nimbus-k8tls/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "nimbus-k8tls.fullname" . }}-clusterrole-binding
name: {{ include "nimbus-k8tls.fullname" . }}
labels:
{{- include "nimbus-k8tls.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: nimbus-k8tls-clusterrole
name: {{ include "nimbus-k8tls.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "nimbus-k8tls.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: k8tls
labels:
{{- include "nimbus-k8tls.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: k8tls
subjects:
- kind: ServiceAccount
name: k8tls
namespace: {{ include "nimbus-k8tls.fullname" . }}-env
2 changes: 2 additions & 0 deletions deployments/nimbus-k8tls/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: Secret
metadata:
name: elasticsearch-password
namespace: {{ include "nimbus-k8tls.fullname" . }}-env
labels:
{{- include "nimbus-k8tls.labels" . | nindent 4 }}
type: Opaque
data:
es_password: {{ .Values.output.elasticsearch.password }}
Expand Down
8 changes: 8 additions & 0 deletions deployments/nimbus-k8tls/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ metadata:
{{- include "nimbus-k8tls.labels" . | nindent 4 }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: k8tls
namespace: {{ include "nimbus-k8tls.fullname" . }}-env
labels:
{{- include "nimbus-k8tls.labels" . | nindent 4 }}
2 changes: 1 addition & 1 deletion pkg/adapter/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ type ContextKey string

const (
K8sClientKey ContextKey = "k8sClient"
NamespaceNameKey ContextKey = "NamespaceName"
NamespaceNameKey ContextKey = "K8tlsNamespace"
)
Loading

0 comments on commit cddd9e9

Please sign in to comment.