-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added fluenbit and karpenter helm chart, IAM policies, merged VPC cha…
…nges (#7)
- Loading branch information
Showing
13 changed files
with
596 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#Cloudwatch Log Group | ||
resource "aws_cloudwatch_log_group" "fluent-bit" { | ||
name = var.fb_log_group_name | ||
retention_in_days = var.fb_log_retention | ||
kms_key_id = var.fb_log_encryption ? var.fb_kms_key_id : "" | ||
tags = var.fb_tags | ||
} | ||
|
||
resource "aws_cloudwatch_log_group" "fluent-bit-system" { | ||
count = var.fb_log_systemd ? 1 : 0 | ||
name = var.fb_system_log_group_name | ||
retention_in_days = var.fb_system_log_retention | ||
kms_key_id = var.fb_log_encryption ? var.fb_kms_key_id : "" | ||
tags = var.fb_tags | ||
} | ||
|
||
#Fluentbit HELM | ||
resource "helm_release" "fluent-bit" { | ||
depends_on = [module.eks, module.main_nodes, module.eks_base] | ||
name = "${local.cluster_name}-fluenbit" | ||
repository = "https://fluent.github.io/helm-charts" | ||
chart = "fluent-bit" | ||
version = var.fb_chart_verison | ||
namespace = "kube-system" | ||
|
||
values = [ | ||
local.values | ||
] | ||
|
||
set { | ||
name = "clusterName" | ||
value = local.cluster_name | ||
} | ||
|
||
set { | ||
name = "serviceAccount.name" | ||
value = "fluent-bit" | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
config: | ||
## https://docs.fluentbit.io/manual/pipeline/inputs | ||
inputs: | | ||
[INPUT] | ||
Name tail | ||
Tag kube.* | ||
Path /var/log/containers/*.log | ||
Read_from_head true | ||
multiline.parser docker, cri | ||
Docker_Mode On | ||
Parser docker | ||
Mem_Buf_Limit 50MB | ||
|
||
[INPUT] | ||
Name systemd | ||
Tag host.* | ||
Systemd_Filter _SYSTEMD_UNIT=kubelet.service | ||
Read_From_Tail On | ||
|
||
${indent(4, inputs)} | ||
|
||
## https://docs.fluentbit.io/manual/pipeline/filters | ||
filters: | | ||
[FILTER] | ||
Name kubernetes | ||
Match kube.* | ||
Merge_Log On | ||
Keep_Log Off | ||
K8S-Logging.Parser On | ||
K8S-Logging.Exclude On | ||
|
||
[FILTER] | ||
Name grep | ||
Match kube.* | ||
Exclude $log ${log_filters} | ||
|
||
[FILTER] | ||
Name grep | ||
Match kube.* | ||
Exclude $log ${additional_log_filters} | ||
|
||
%{ for value in kube_namespaces } | ||
[FILTER] | ||
Name rewrite_tag | ||
Match kube.* | ||
Rule $kubernetes['namespace_name'] ^${value}$ system.$TAG false | ||
%{ endfor ~} | ||
|
||
[FILTER] | ||
Name grep | ||
Match * | ||
Exclude $kubernetes['namespace_name'] ${drop_namespaces} | ||
|
||
${indent(4, filters)} | ||
outputs: | | ||
[OUTPUT] | ||
Name cloudwatch_logs | ||
Match kube.* | ||
region ${region} | ||
log_group_name ${log_group_name} | ||
log_stream_prefix from-fluent-bit- | ||
log_retention_days ${log_retention_days} | ||
|
||
[OUTPUT] | ||
Name cloudwatch_logs | ||
Match host.* | ||
region ${region} | ||
log_group_name ${system_log_group_name} | ||
log_stream_prefix eks- | ||
log_retention_days ${log_retention_days} | ||
|
||
[OUTPUT] | ||
Name cloudwatch_logs | ||
Match system.* | ||
region ${region} | ||
log_group_name ${system_log_group_name} | ||
log_stream_prefix from-fluent-bit- | ||
auto_create_group ${auto_create_group} | ||
log_retention_days ${log_retention_days} | ||
|
||
${indent(4, outputs)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
description: A Helm chart for Karpenter Nodes | ||
name: karpenter-nodes | ||
version: 1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
apiVersion: karpenter.k8s.aws/v1beta1 | ||
kind: EC2NodeClass | ||
metadata: | ||
name: {{ .Values.nodeClass.metadata.name | default "default" | quote }} | ||
annotations: | ||
{{- range $key, $value := .Values.nodeClass.metadata.annotations }} | ||
{{ $key }}: "{{ $value }}" | ||
{{- end }} | ||
spec: | ||
amiFamily: {{ .Values.nodeClass.spec.amiFamily | default "AL2" | quote }} | ||
blockDeviceMappings: | ||
{{- range .Values.nodeClass.spec.blockDeviceMappings }} | ||
- deviceName: {{ .deviceName | quote }} | ||
ebs: | ||
volumeType: {{ .ebs.volumeType | quote }} | ||
volumeSize: {{ .ebs.volumeSize | quote }} | ||
deleteOnTermination: {{ .ebs.deleteOnTermination | quote }} | ||
{{- end }} | ||
role: "{{ .Values.nodeClass.spec.role }}" | ||
associatePublicIPAddress: {{ .Values.nodeClass.spec.associatePublicIPAddress | default false }} | ||
subnetSelectorTerms: | ||
- tags: | ||
Name: "{{ .Values.nodeClass.spec.subnetTag }}" | ||
securityGroupSelectorTerms: | ||
- tags: | ||
karpenter.sh/discovery: "{{ .Values.nodeClass.spec.clustername }}" | ||
- id: "{{ .Values.nodeClass.spec.securityGroupID }}" | ||
tags: | ||
{{- range $key, $value := .Values.nodeClass.spec.tags }} | ||
{{ $key }}: "{{ $value }}" | ||
{{- end }} | ||
userData: | | ||
{{- if .Values.nodeClass.spec.userData }} | ||
{{ .Values.nodeClass.spec.userData | indent 4 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: karpenter.sh/v1beta1 | ||
kind: NodePool | ||
metadata: | ||
name: {{ .Values.nodePool.metadata.name | default "default" | quote }} | ||
annotations: | ||
{{- range $key, $value := .Values.nodePool.metadata.annotations }} | ||
{{ $key }}: "{{ $value }}" | ||
{{- end }} | ||
spec: | ||
template: | ||
spec: | ||
requirements: | ||
{{- range .Values.nodePool.spec.template.spec.requirements }} | ||
- key: {{ .key | quote }} | ||
operator: {{ .operator | quote }} | ||
values: [{{ range $index, $value := .values }}{{ if $index }}, {{ end }}"{{ $value }}"{{ end }}] | ||
{{- end }} | ||
nodeClassRef: | ||
apiVersion: {{ .Values.nodePool.spec.template.spec.nodeClassRef.apiVersion | default "karpenter.k8s.aws/v1beta1" | quote }} | ||
kind: {{ .Values.nodePool.spec.template.spec.nodeClassRef.kind | default "EC2NodeClass" | quote }} | ||
name: {{ .Values.nodePool.spec.template.spec.nodeClassRef.name | default "default" | quote }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
nodeClass: | ||
metadata: | ||
name: "default" | ||
annotations: | ||
description: "EC2NodeClass for running Amazon Linux 2 nodes with custom user data" | ||
|
||
spec: | ||
amiFamily: ${amiFamily} | ||
blockDeviceMappings: | ||
- deviceName: "/dev/xvda" | ||
ebs: | ||
volumeType: "gp3" | ||
volumeSize: 5 | ||
deleteOnTermination: true | ||
- deviceName: "/dev/xvdb" | ||
ebs: | ||
volumeType: "gp3" | ||
volumeSize: 100 | ||
deleteOnTermination: true | ||
role: ${iamRole} | ||
subnetTag: ${subnetTag} | ||
securityGroupID: ${securityGroupID} | ||
tags: | ||
${tags} | ||
|
||
nodePool: | ||
metadata: | ||
name: "default" | ||
annotations: | ||
kubernetes.io/description: "General purpose NodePool for generic workloads" | ||
spec: | ||
template: | ||
spec: | ||
requirements: | ||
- key: "kubernetes.io/arch" | ||
operator: "In" | ||
values: ["amd64"] | ||
- key: "kubernetes.io/os" | ||
operator: "In" | ||
values: ["linux"] | ||
- key: "karpenter.sh/capacity-type" | ||
operator: "In" | ||
values: ["on-demand"] | ||
- key: "karpenter.k8s.aws/instance-category" | ||
operator: "In" | ||
values: ["c", "m", "r"] | ||
- key: "karpenter.k8s.aws/instance-generation" | ||
operator: "Gt" | ||
values: ["5"] | ||
- key: "usage" | ||
operator: "In" | ||
values: ["application", "system"] | ||
nodeClassRef: | ||
apiVersion: "karpenter.k8s.aws/v1beta1" | ||
kind: "EC2NodeClass" | ||
name: "default" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
controller: | ||
tolerations: | ||
- key: "CriticalAddonsOnly" | ||
operator: "Exists" | ||
effect: "NoSchedule" | ||
|
||
webhook: | ||
tolerations: | ||
- key: "CriticalAddonsOnly" | ||
operator: "Exists" | ||
effect: "NoSchedule" | ||
|
||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: usage | ||
operator: In | ||
values: | ||
- karpenter | ||
podAntiAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- topologyKey: "kubernetes.io/hostname" | ||
settings: | ||
clusterName: ${cluster_name} | ||
interruptionQueue: "Karpenter-"${cluster_name} |
Oops, something went wrong.