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

reuse workload #245

Merged
merged 1 commit into from
Oct 18, 2023
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
4 changes: 0 additions & 4 deletions charts/crds/kdoctor.io_apphttphealthies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ spec:
spec:
properties:
agentSpec:
default:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个feature 对 原理的新建逻辑 为什么有修改

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 feature 如果不填写 agentSpec 使用默认的 agent 执行任务,所以将原 agent 改为指针类型,原有的 agent 存在 默认值,会导致无论怎么做都有 agentspec 字段,这个默认值 只是 agentspec 的默认值,不是 agentspec里字段的默认值

hostNetwork: false
kind: DaemonSet
terminationGracePeriodMinutes: 60
properties:
affinity:
description: Affinity is a group of affinity scheduling rules.
Expand Down
4 changes: 0 additions & 4 deletions charts/crds/kdoctor.io_netdnses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ spec:
spec:
properties:
agentSpec:
default:
hostNetwork: false
kind: DaemonSet
terminationGracePeriodMinutes: 60
properties:
affinity:
description: Affinity is a group of affinity scheduling rules.
Expand Down
4 changes: 0 additions & 4 deletions charts/crds/kdoctor.io_netreaches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ spec:
spec:
properties:
agentSpec:
default:
hostNetwork: false
kind: DaemonSet
terminationGracePeriodMinutes: 60
properties:
affinity:
description: Affinity is a group of affinity scheduling rules.
Expand Down
4 changes: 2 additions & 2 deletions charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
kdoctorAgent Selector labels
*/}}
{{- define "project.kdoctorAgent.selectorLabels" -}}
app.kubernetes.io/name: {{ include "project.name" . }}
app.kubernetes.io/name: {{ .Values.kdoctorAgent.name | trunc 63 | trimSuffix "-" }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: {{ .Values.kdoctorAgent.name | trunc 63 | trimSuffix "-" }}
{{- end }}
Expand All @@ -49,7 +49,7 @@ app.kubernetes.io/component: {{ .Values.kdoctorAgent.name | trunc 63 | trimSuffi
kdoctorController Selector labels
*/}}
{{- define "project.kdoctorController.selectorLabels" -}}
app.kubernetes.io/name: {{ include "project.name" . }}
app.kubernetes.io/name: {{ .Values.kdoctorController.name | trunc 63 | trimSuffix "-" }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: {{ .Values.kdoctorController.name | trunc 63 | trimSuffix "-" }}
{{- end }}
Expand Down
1 change: 1 addition & 0 deletions charts/templates/configmap-app-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ data:
selector:
matchLabels:
{{- include "project.kdoctorAgent.selectorLabels" . | nindent 10 }}
# template for performing tasks
pod.yml: |
apiVersion: v1
kind: Pod
Expand Down
242 changes: 242 additions & 0 deletions charts/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ .Values.kdoctorAgent.name | trunc 63 | trimSuffix "-" }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "project.kdoctorAgent.labels" . | nindent 4 }}
{{- if .Values.global.commonLabels }}
{{- include "tplvalues.render" ( dict "value" .Values.global.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.global.commonAnnotations }}
annotations:
{{- include "tplvalues.render" ( dict "value" .Values.global.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "project.kdoctorAgent.selectorLabels" . | nindent 6 }}
{{- with .Values.kdoctorAgent.updateStrategy }}
updateStrategy:
{{- toYaml . | trim | nindent 4 }}
{{- end }}
template:
metadata:
{{- if or .Values.kdoctorAgent.podAnnotations .Values.global.commonAnnotations }}
annotations:
{{- if .Values.global.commonAnnotations }}
{{- include "tplvalues.render" ( dict "value" .Values.global.commonAnnotations "context" $ ) | nindent 8 }}
{{- end }}
{{- if .Values.kdoctorAgent.podAnnotations }}
{{- include "tplvalues.render" ( dict "value" .Values.kdoctorAgent.podAnnotations "context" $ ) | nindent 8 }}
{{- end }}
{{- end }}
labels:
{{- include "project.kdoctorAgent.selectorLabels" . | nindent 8 }}
{{- if .Values.global.commonLabels }}
{{- include "tplvalues.render" ( dict "value" .Values.global.commonLabels "context" $ ) | nindent 8 }}
{{- end }}
{{- if .Values.kdoctorAgent.podLabels }}
{{- include "tplvalues.render" ( dict "value" .Values.kdoctorAgent.podLabels "context" $ ) | nindent 8 }}
{{- end }}
spec:
{{- if .Values.kdoctorAgent.image.imagePullSecrets }}
imagePullSecrets:
{{- with .Values.kdoctorAgent.image.imagePullSecrets }}
{{- toYaml . | trim | nindent 6 }}
{{- end }}
{{- end }}
serviceAccountName: {{ .Values.kdoctorAgent.name | trunc 63 | trimSuffix "-" }}
priorityClassName: {{ default "system-node-critical" .Values.kdoctorAgent.priorityClassName }}
{{- if .Values.kdoctorAgent.hostnetwork }}
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
{{- else }}
hostNetwork: false
dnsPolicy: ClusterFirst
{{- end }}
restartPolicy: Always
{{- with .Values.kdoctorAgent.tolerations }}
tolerations:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.kdoctorAgent.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.kdoctorAgent.affinity }}
affinity:
{{- include "tplvalues.render" (dict "value" .Values.kdoctorAgent.affinity "context" $) | nindent 6 }}
{{- else }}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/os
operator: In
values:
- linux
# Compatible with Kubernetes 1.12.x and 1.13.x
- matchExpressions:
- key: beta.kubernetes.io/os
operator: In
values:
- linux
{{- end }}
containers:
- name: {{ .Values.kdoctorAgent.name | trunc 63 | trimSuffix "-" }}
image: {{ include "project.kdoctorAgent.image" . | quote }}
imagePullPolicy: {{ .Values.kdoctorAgent.image.pullPolicy }}
command:
- {{ .Values.kdoctorAgent.cmdBinName }}
args:
- --config-path=/tmp/config-map/conf.yml
- --tls-ca-cert=/etc/tls/ca.crt
- --tls-ca-key=/etc/tls/ca.key
- --default-agent=true
{{- if .Values.feature.enableIPv4 }}
- --service-ipv4-name={{ include "project.kdoctorAgent.serviceIpv4Name" . }}
{{- end }}
{{- if .Values.feature.enableIPv6 }}
- --service-ipv6-name={{ include "project.kdoctorAgent.serviceIpv6Name" . }}
{{- end }}
{{- with .Values.kdoctorAgent.extraArgs }}
{{- toYaml . | trim | nindent 8 }}
{{- end }}
ports:
{{- if .Values.kdoctorAgent.prometheus.enabled }}
- name: metrics
containerPort: {{ .Values.kdoctorAgent.prometheus.port }}
protocol: TCP
{{- end }}
{{- if or .Values.feature.enableIPv4 .Values.feature.enableIPv6 }}
- name: health
containerPort: {{ .Values.kdoctorAgent.httpServer.healthPort }}
protocol: TCP
- name: http
containerPort: {{ .Values.kdoctorAgent.httpServer.appHttpPort }}
protocol: TCP
- name: https
containerPort: {{ .Values.kdoctorAgent.httpServer.appHttpsPort }}
protocol: TCP
{{- end }}
{{- if semverCompare ">=1.20-0" .Capabilities.KubeVersion.Version }}
startupProbe:
httpGet:
path: /healthy/startup
port: {{ .Values.kdoctorAgent.httpServer.healthPort }}
scheme: HTTP
failureThreshold: {{ .Values.kdoctorAgent.httpServer.startupProbe.failureThreshold }}
periodSeconds: {{ .Values.kdoctorAgent.httpServer.startupProbe.periodSeconds }}
successThreshold: 1
{{- end }}
livenessProbe:
httpGet:
path: /healthy/liveness
port: {{ .Values.kdoctorAgent.httpServer.healthPort }}
scheme: HTTP
initialDelaySeconds: 60
periodSeconds: {{ .Values.kdoctorAgent.httpServer.livenessProbe.periodSeconds }}
successThreshold: 1
failureThreshold: {{ .Values.kdoctorAgent.httpServer.livenessProbe.failureThreshold }}
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /healthy/readiness
port: {{ .Values.kdoctorAgent.httpServer.healthPort }}
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: {{ .Values.kdoctorAgent.httpServer.readinessProbe.periodSeconds }}
successThreshold: 1
failureThreshold: {{ .Values.kdoctorAgent.httpServer.readinessProbe.failureThreshold }}
timeoutSeconds: 5
{{- with .Values.kdoctorAgent.resources }}
resources:
{{- toYaml . | trim | nindent 12 }}
{{- end }}
env:
- name: ENV_LOG_LEVEL
value: {{ .Values.kdoctorAgent.debug.logLevel | quote }}
- name: ENV_ENABLED_METRIC
value: {{ .Values.kdoctorAgent.prometheus.enabled | quote }}
- name: ENV_METRIC_HTTP_PORT
value: {{ .Values.kdoctorAgent.prometheus.port | quote }}
- name: ENV_AGENT_HEALTH_HTTP_PORT
value: {{ .Values.kdoctorAgent.httpServer.healthPort | quote }}
- name: ENV_AGENT_APP_HTTP_PORT
value: {{ .Values.kdoctorAgent.httpServer.appHttpPort | quote }}
- name: ENV_AGENT_APP_HTTPS_PORT
value: {{ .Values.kdoctorAgent.httpServer.appHttpsPort | quote }}
- name: ENV_GOPS_LISTEN_PORT
value: {{ .Values.kdoctorAgent.debug.gopsPort | quote }}
- name: ENV_AGENT_GRPC_LISTEN_PORT
value: {{ .Values.kdoctorAgent.grpcServer.port | quote }}
- name: ENV_CLUSTER_DNS_DOMAIN
value: {{ .Values.global.clusterDnsDomain | quote }}
- name: ENV_ENABLE_AGGREGATE_AGENT_REPORT
value: {{ .Values.feature.aggregateReport.enabled | quote }}
{{- if .Values.feature.aggregateReport.enabled }}
- name: ENV_AGENT_REPORT_STORAGE_PATH
value: {{ .Values.feature.aggregateReport.agent.reportPath | quote }}
- name: ENV_CLEAN_AGED_REPORT_INTERVAL_IN_MINUTE
value: {{ .Values.feature.aggregateReport.cleanAgedReportIntervalInMinute | quote }}
{{- end }}
- name: ENV_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: ENV_LOCAL_NODE_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: ENV_LOCAL_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: ENV_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
{{- with .Values.kdoctorAgent.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.kdoctorAgent.securityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
volumeMounts:
- name: config-path
mountPath: /tmp/config-map
readOnly: true
- name: report-data
mountPath: /report
- name: tls
mountPath: /etc/tls
{{- if .Values.kdoctorAgent.extraVolumes }}
{{- include "tplvalues.render" ( dict "value" .Values.kdoctorAgent.extraVolumeMounts "context" $ ) | nindent 12 }}
{{- end }}
volumes:
# To read the configuration from the config map
- name: config-path
configMap:
defaultMode: 0400
name: {{ .Values.global.configName }}
- name: report-data
hostPath:
path: {{ .Values.kdoctorAgent.reportHostPath }}
type: DirectoryOrCreate
- name: tls
projected:
defaultMode: 0400
sources:
- secret:
items:
- key: tls.key
path: ca.key
- key: tls.crt
path: ca.crt
name: {{ .Values.tls.ca.secretName }}
{{- if .Values.kdoctorAgent.extraVolumeMounts }}
{{- include "tplvalues.render" ( dict "value" .Values.kdoctorAgent.extraVolumeMounts "context" $ ) | nindent 6 }}
{{- end }}
14 changes: 12 additions & 2 deletions charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ spec:
value: {{ .Values.kdoctorController.httpServer.port | quote }}
- name: ENV_AGENT_GRPC_LISTEN_PORT
value: {{ .Values.kdoctorAgent.grpcServer.port | quote }}
- name: ENV_AGENT_DAEMONSET_NAME
value: {{ .Values.kdoctorAgent.name | trunc 63 | trimSuffix "-" }}
- name: ENV_ENABLE_AGGREGATE_AGENT_REPORT
value: {{ .Values.feature.aggregateReport.enabled | quote }}
{{- if .Values.feature.aggregateReport.enabled }}
Expand All @@ -163,6 +161,18 @@ spec:
value: {{ .Values.feature.aggregateReport.cleanAgedReportIntervalInMinute | quote }}
- name: ENV_COLLECT_AGENT_REPORT_INTERVAL_IN_SECOND
value: {{ .Values.feature.aggregateReport.controller.collectAgentReportIntervalInSecond | quote }}
- name: ENV_DEFAULT_AGENT_NAME
value: {{ .Values.kdoctorAgent.name | trunc 63 | trimSuffix "-" }}
- name: ENV_DEFAULT_AGENT_TYPE
value: DaemonSet
{{- if .Values.feature.enableIPv4 }}
- name: ENV_DEFAULT_AGENT_SERVICE_V4_NAME
value: {{ include "project.kdoctorAgent.serviceIpv4Name" . }}
{{- end }}
{{- if .Values.feature.enableIPv6 }}
- name: ENV_DEFAULT_AGENT_SERVICE_V6_NAME
value: {{ include "project.kdoctorAgent.serviceIpv6Name" . }}
{{- end }}
{{- end }}
- name: ENV_POD_NAME
valueFrom:
Expand Down
25 changes: 25 additions & 0 deletions charts/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.kdoctorAgent.ingress.enable }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "project.kdoctorAgent.ingressName" . }}
namespace: {{ .Release.Namespace | quote }}
spec:
{{- if .Values.kdoctorAgent.ingress.ingressClass }}
ingressClassName: {{ .Values.kdoctorAgent.ingress.ingressClass | quote }}
{{- end }}
rules:
- http:
paths:
- path: {{ .Values.kdoctorAgent.ingress.route | quote }}
pathType: Exact
backend:
service:
{{- if .Values.feature.enableIPv4 }}
name: {{ include "project.kdoctorAgent.serviceIpv4Name" . }}
{{- else }}
name: {{ include "project.kdoctorAgent.serviceIpv6Name" . }}
{{- end }}
port:
number: {{ .Values.kdoctorAgent.httpServer.appHttpPort }}
{{- end }}
Loading
Loading