Skip to content

Commit

Permalink
feat: add tke event collector charts (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shangru-WU authored Nov 12, 2024
1 parent 5a6655a commit d7fb2b6
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 0 deletions.
23 changes: 23 additions & 0 deletions incubator/tke-event-collector/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
5 changes: 5 additions & 0 deletions incubator/tke-event-collector/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
appVersion: 0.0.6
description: helm chart for tke-event-collector
name: tke-event-collector
version: 0.0.6
37 changes: 37 additions & 0 deletions incubator/tke-event-collector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# TKE Event Collector

## Introduction

`tke-event-collector` is responsible for collect events of a k8s cluster and push the events to CLS for persistence.

## Prerequisites

- Helm 3.1.0+
- TKE Resilience v1.0.0+

## Installing the Chart

```console
helm -n kube-system install tke-event-collector ./tke-event-collector
```

## Uninstalling the Chart

To uninstall/delete the `tke-event-collector` deployment:

```console
helm -n kube-system uninstall tke-event-collector
```

## Parameters

| Name | Description | Value |
| --------------------| -----------------------| ------------------------------------------|
| `replicas` | 容器副本数 | 1 |
| `topicId` | 事件上报的日志主题 | `5450c7b5-xxxx-xxxx-xxxx-xxxxxxxxxxxx` |
| `clsHost` | 事件上报服务器地址 | `ap-beijing.cls.tencentyun.com` |
| `requestRegion` | 事件上报地域 | `ap-beijing` |
| `clusterId` | 集群 ID 标识 | `xxxx` |
| `logLevel` | 日志等级 | 5 |
| `imageTag` | 容器镜像版本 | `v0.0.6` |
| `imagePullPolicy` | 容器镜像更新策略 | `IfNotPresent` |
62 changes: 62 additions & 0 deletions incubator/tke-event-collector/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "tke-event-collector.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "tke-event-collector.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "tke-event-collector.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "tke-event-collector.labels" -}}
helm.sh/chart: {{ include "tke-event-collector.chart" . }}
{{ include "tke-event-collector.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "tke-event-collector.selectorLabels" -}}
app.kubernetes.io/name: {{ include "tke-event-collector.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "tke-event-collector.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "tke-event-collector.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
26 changes: 26 additions & 0 deletions incubator/tke-event-collector/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: tke-event-collector
rules:
- apiGroups:
- ""
resources:
- "events"
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: tke-event-collector
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: tke-event-collector
subjects:
- kind: ServiceAccount
name: tke-event-collector
namespace: {{ .Release.Namespace }}
72 changes: 72 additions & 0 deletions incubator/tke-event-collector/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: tke-event-collector
namespace: {{ .Release.Namespace }}
labels:
app: tke-event-collector
spec:
minReadySeconds: 10
replicas: {{ .Values.global.replicas }}
selector:
matchLabels:
app: tke-event-collector
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app: tke-event-collector
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node.kubernetes.io/instance-type
operator: In
values:
- eklet
serviceAccountName: tke-event-collector
containers:
- command:
- kube-event-collector
- --topic-id={{ .Values.global.topicId }}
- --cls-host={{ .Values.global.clsHost }}
- --cluster-id={{ .Values.global.clusterId }}
{{- if .Values.global.requestRegion }}
- --request-region={{ .Values.global.requestRegion }}
{{- end }}
- --cred-source=anony
- --v={{ .Values.global.logLevel }}
env:
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
image: "{{.Values.global.registry}}/{{.Values.global.repository}}:{{.Values.global.imageTag}}"
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
name: tke-event-collector
resources:
limits:
cpu: 1
memory: 1024M
requests:
cpu: 200m
memory: 256M
{{- if .Values.global.hostAliases }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.global.hostAliases "context" $) | nindent 8 }}
{{- end }}
dnsPolicy: "None"
dnsConfig:
nameservers:
- 183.60.83.19
- 183.60.82.98
5 changes: 5 additions & 0 deletions incubator/tke-event-collector/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: tke-event-collector
namespace: {{ .Release.Namespace }}
18 changes: 18 additions & 0 deletions incubator/tke-event-collector/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Default values for tke-event-collector.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.


global:
replicas: 1
topicId: "5450c7b5-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
clsHost: "ap-beijing.cls.tencentyun.com"
requestRegion: "ap-beijing"
clusterId: "xxxx"
logLevel: 5
registry: ccr.ccs.tencentyun.com
repository: tkeimages/kube-event-collector
imageTag: v0.0.6
imagePullPolicy: IfNotPresent
annotations: {}
hostAliases: {}

0 comments on commit d7fb2b6

Please sign in to comment.