Skip to content

Commit

Permalink
Revert "refactor: preparation for gateway conformance test (#266)"
Browse files Browse the repository at this point in the history
This reverts commit c1df0db.
  • Loading branch information
reaver-flomesh committed Jun 20, 2024
1 parent 4be6b9e commit c550d52
Show file tree
Hide file tree
Showing 106 changed files with 3,827 additions and 6,067 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
version: v1.55
skip-pkg-cache: true

codegen:
Expand Down
8 changes: 0 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ run:
timeout: 20m

linters:
disable:
- errcheck
enable:
- goconst
- gocyclo
Expand All @@ -24,18 +22,12 @@ linters-settings:
rules:
- name: unused-parameter
disabled: true
gosec:
exclude-generated: true
severity: medium
confidence: medium

issues:
exclude-dirs:
- pkg/gen
- pkg/bugreport
exclude-files:
- "zz_generated.deepcopy.go$"
- "zz_generated.register.go$"
exclude-rules:
# Ignore error for ginkgo and gomega dot imports
- linters:
Expand Down
80 changes: 37 additions & 43 deletions charts/gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,50 +59,44 @@ The following table lists the configurable parameters of the fsm chart and their

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| fsm.fsmGateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key | string | `"kubernetes.io/os"` | |
| fsm.fsmGateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].operator | string | `"In"` | |
| fsm.fsmGateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].values[0] | string | `"linux"` | |
| fsm.fsmGateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[1].key | string | `"kubernetes.io/arch"` | |
| fsm.fsmGateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[1].operator | string | `"In"` | |
| fsm.fsmGateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[1].values[0] | string | `"amd64"` | |
| fsm.fsmGateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[1].values[1] | string | `"arm64"` | |
| fsm.fsmGateway.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].key | string | `"app"` | |
| fsm.fsmGateway.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].operator | string | `"In"` | |
| fsm.fsmGateway.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].values[0] | string | `"fsm-gateway"` | |
| fsm.fsmGateway.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.topologyKey | string | `"kubernetes.io/hostname"` | |
| fsm.fsmGateway.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].weight | int | `100` | |
| fsm.fsmGateway.autoScale | object | `{"behavior":{"scaleDown":{"policies":[{"periodSeconds":60,"type":"Pods","value":1},{"periodSeconds":60,"type":"Percent","value":10}],"selectPolicy":"Min","stabilizationWindowSeconds":300},"scaleUp":{"policies":[{"periodSeconds":15,"type":"Percent","value":100},{"periodSeconds":15,"type":"Pods","value":2}],"selectPolicy":"Max","stabilizationWindowSeconds":0}},"cpu":{"targetAverageUtilization":80},"enable":false,"maxReplicas":10,"memory":{"targetAverageUtilization":80},"metrics":[{"resource":{"name":"cpu","target":{"averageUtilization":80,"type":"Utilization"}},"type":"Resource"},{"resource":{"name":"memory","target":{"averageUtilization":80,"type":"Utilization"}},"type":"Resource"}],"minReplicas":1}` | Auto scale configuration |
| fsm.fsmGateway.autoScale.behavior | object | `{"scaleDown":{"policies":[{"periodSeconds":60,"type":"Pods","value":1},{"periodSeconds":60,"type":"Percent","value":10}],"selectPolicy":"Min","stabilizationWindowSeconds":300},"scaleUp":{"policies":[{"periodSeconds":15,"type":"Percent","value":100},{"periodSeconds":15,"type":"Pods","value":2}],"selectPolicy":"Max","stabilizationWindowSeconds":0}}` | Auto scale behavior, for v2 API |
| fsm.fsmGateway.autoScale.cpu | object | `{"targetAverageUtilization":80}` | Auto scale cpu metrics, for v2beta2 API |
| fsm.fsmGateway.autoScale.cpu.targetAverageUtilization | int | `80` | Average target CPU utilization (%) |
| fsm.fsmGateway.autoScale.enable | bool | `false` | Enable Autoscale |
| fsm.fsmGateway.autoScale.maxReplicas | int | `10` | Maximum replicas for autoscale |
| fsm.fsmGateway.autoScale.memory | object | `{"targetAverageUtilization":80}` | Auto scale memory metrics, for v2beta2 API |
| fsm.fsmGateway.autoScale.memory.targetAverageUtilization | int | `80` | Average target memory utilization (%) |
| fsm.fsmGateway.autoScale.metrics | list | `[{"resource":{"name":"cpu","target":{"averageUtilization":80,"type":"Utilization"}},"type":"Resource"},{"resource":{"name":"memory","target":{"averageUtilization":80,"type":"Utilization"}},"type":"Resource"}]` | Auto scale metrics, for v2 API |
| fsm.fsmGateway.autoScale.minReplicas | int | `1` | Minimum replicas for autoscale |
| fsm.fsmGateway.env[0].name | string | `"GIN_MODE"` | |
| fsm.fsmGateway.env[0].value | string | `"release"` | |
| fsm.fsmGateway.initResources | object | `{"limits":{"cpu":"500m","memory":"512M"},"requests":{"cpu":"200m","memory":"128M"}}` | initContainer resource configuration |
| fsm.fsmGateway.logLevel | string | `"info"` | |
| fsm.fsmGateway.nodeSelector | object | `{}` | Node selector applied to control plane pods. |
| fsm.fsmGateway.podAnnotations | object | `{}` | FSM Gateway Controller's pod annotations |
| fsm.fsmGateway.podDisruptionBudget | object | `{"enabled":false,"minAvailable":1}` | Pod disruption budget configuration |
| fsm.fsmGateway.podDisruptionBudget.enabled | bool | `false` | Enable Pod Disruption Budget |
| fsm.fsmGateway.podDisruptionBudget.minAvailable | int | `1` | Minimum number of pods that must be available |
| fsm.fsmGateway.podLabels | object | `{}` | FSM Gateway Controller's pod labels |
| fsm.fsmGateway.podSecurityContext | object | `{"runAsGroup":65532,"runAsNonRoot":true,"runAsUser":65532,"seccompProfile":{"type":"RuntimeDefault"}}` | FSM Gateway Controller's pod security context |
| fsm.fsmGateway.replicas | int | `1` | |
| fsm.fsmGateway.resources | object | `{"limits":{"cpu":"2","memory":"1G"},"requests":{"cpu":"0.5","memory":"128M"}}` | FSM Gateway's container resource parameters. |
| fsm.fsmGateway.securityContext | object | `{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]}}` | FSM Gateway Controller's container security context |
| fsm.fsmGateway.tolerations | list | `[]` | Node tolerations applied to control plane pods. The specified tolerations allow pods to schedule onto nodes with matching taints. |
| fsm.fsmNamespace | string | `""` | Namespace to deploy FSM in. If not specified, the Helm release namespace is used. |
| fsm.gateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key | string | `"kubernetes.io/os"` | |
| fsm.gateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].operator | string | `"In"` | |
| fsm.gateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].values[0] | string | `"linux"` | |
| fsm.gateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[1].key | string | `"kubernetes.io/arch"` | |
| fsm.gateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[1].operator | string | `"In"` | |
| fsm.gateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[1].values[0] | string | `"amd64"` | |
| fsm.gateway.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[1].values[1] | string | `"arm64"` | |
| fsm.gateway.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].key | string | `"app"` | |
| fsm.gateway.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].operator | string | `"In"` | |
| fsm.gateway.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].values[0] | string | `"fsm-gateway"` | |
| fsm.gateway.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.topologyKey | string | `"kubernetes.io/hostname"` | |
| fsm.gateway.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].weight | int | `100` | |
| fsm.gateway.autoScale | object | `{"behavior":{"scaleDown":{"policies":[{"periodSeconds":60,"type":"Pods","value":1},{"periodSeconds":60,"type":"Percent","value":10}],"selectPolicy":"Min","stabilizationWindowSeconds":300},"scaleUp":{"policies":[{"periodSeconds":15,"type":"Percent","value":100},{"periodSeconds":15,"type":"Pods","value":2}],"selectPolicy":"Max","stabilizationWindowSeconds":0}},"cpu":{"targetAverageUtilization":80},"enable":false,"maxReplicas":10,"memory":{"targetAverageUtilization":80},"metrics":[{"resource":{"name":"cpu","target":{"averageUtilization":80,"type":"Utilization"}},"type":"Resource"},{"resource":{"name":"memory","target":{"averageUtilization":80,"type":"Utilization"}},"type":"Resource"}],"minReplicas":1}` | Auto scale configuration |
| fsm.gateway.autoScale.behavior | object | `{"scaleDown":{"policies":[{"periodSeconds":60,"type":"Pods","value":1},{"periodSeconds":60,"type":"Percent","value":10}],"selectPolicy":"Min","stabilizationWindowSeconds":300},"scaleUp":{"policies":[{"periodSeconds":15,"type":"Percent","value":100},{"periodSeconds":15,"type":"Pods","value":2}],"selectPolicy":"Max","stabilizationWindowSeconds":0}}` | Auto scale behavior, for v2 API |
| fsm.gateway.autoScale.cpu | object | `{"targetAverageUtilization":80}` | Auto scale cpu metrics, for v2beta2 API |
| fsm.gateway.autoScale.cpu.targetAverageUtilization | int | `80` | Average target CPU utilization (%) |
| fsm.gateway.autoScale.enable | bool | `false` | Enable Autoscale |
| fsm.gateway.autoScale.maxReplicas | int | `10` | Maximum replicas for autoscale |
| fsm.gateway.autoScale.memory | object | `{"targetAverageUtilization":80}` | Auto scale memory metrics, for v2beta2 API |
| fsm.gateway.autoScale.memory.targetAverageUtilization | int | `80` | Average target memory utilization (%) |
| fsm.gateway.autoScale.metrics | list | `[{"resource":{"name":"cpu","target":{"averageUtilization":80,"type":"Utilization"}},"type":"Resource"},{"resource":{"name":"memory","target":{"averageUtilization":80,"type":"Utilization"}},"type":"Resource"}]` | Auto scale metrics, for v2 API |
| fsm.gateway.autoScale.minReplicas | int | `1` | Minimum replicas for autoscale |
| fsm.gateway.env[0].name | string | `"GIN_MODE"` | |
| fsm.gateway.env[0].value | string | `"release"` | |
| fsm.gateway.infrastructure | object | `{"annotations":{},"labels":{}}` | Gateway's infrastructure, override by gateway.spec.infrastructure.annotations and gateway.spec.infrastructure.labels -- NOT override by parameterRef |
| fsm.gateway.initResources | object | `{"limits":{"cpu":"500m","memory":"512M"},"requests":{"cpu":"200m","memory":"128M"}}` | initContainer resource configuration |
| fsm.gateway.listeners | object | `{}` | Gateway's listeners, not overridable by parameterRef |
| fsm.gateway.logLevel | string | `"info"` | |
| fsm.gateway.name | string | `"UNKNOWN"` | Gateway's name, not overridable by parameterRef |
| fsm.gateway.namespace | string | `"default"` | Gateway's namespace, not overridable by parameterRef |
| fsm.gateway.nodePorts | list | `[]` | NodePort service configuration nodePorts: - port: 80 nodePort: 30080 - port: 443 nodePort: 30443 - port: 53 nodePort: 30053 |
| fsm.gateway.nodeSelector | object | `{}` | Node selector applied to control plane pods. |
| fsm.gateway.podAnnotations | object | `{}` | FSM Gateway Controller's pod annotations |
| fsm.gateway.podDisruptionBudget | object | `{"enabled":false,"minAvailable":1}` | Pod disruption budget configuration |
| fsm.gateway.podDisruptionBudget.enabled | bool | `false` | Enable Pod Disruption Budget |
| fsm.gateway.podDisruptionBudget.minAvailable | int | `1` | Minimum number of pods that must be available |
| fsm.gateway.podLabels | object | `{}` | FSM Gateway Controller's pod labels |
| fsm.gateway.podSecurityContext | object | `{"runAsGroup":65532,"runAsNonRoot":true,"runAsUser":65532,"seccompProfile":{"type":"RuntimeDefault"}}` | FSM Gateway Controller's pod security context |
| fsm.gateway.replicas | int | `1` | FSM Gateway's replica count |
| fsm.gateway.resources | object | `{"limits":{"cpu":"2","memory":"1G"},"requests":{"cpu":"0.5","memory":"128M"}}` | FSM Gateway's container resource parameters. |
| fsm.gateway.securityContext | object | `{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]}}` | FSM Gateway Controller's container security context |
| fsm.gateway.serviceType | string | `"LoadBalancer"` | FSM Gateway's service type, only LoadBalancer and NodePort are supported |
| fsm.gateway.tolerations | list | `[]` | Node tolerations applied to control plane pods. The specified tolerations allow pods to schedule onto nodes with matching taints. |
| fsm.image.digest | object | `{"fsmCurl":"","fsmGateway":""}` | Image digest (defaults to latest compatible tag) |
| fsm.image.digest.fsmCurl | string | `""` | fsm-curl's image digest |
| fsm.image.digest.fsmGateway | string | `""` | fsm-gateway's image digest |
Expand Down
2 changes: 1 addition & 1 deletion charts/gateway/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ServiceAccountName - GatewayAPI
*/}}
{{- define "fsm.gateway.serviceAccountName" -}}
{{ printf "fsm-gateway-%s-%s" .Values.fsm.gateway.namespace .Values.fsm.gateway.name }}
{{ printf "fsm-gateway-%s" .Values.gwy.metadata.namespace }}
{{- end }}

{{/* fsm-gateway image */}}
Expand Down
60 changes: 26 additions & 34 deletions charts/gateway/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ printf "fsm-gateway-%s-%s" .Values.fsm.gateway.namespace .Values.fsm.gateway.name }}
namespace: {{ .Values.fsm.gateway.namespace }}
{{- if .Values.fsm.gateway.infrastructure }}
{{- with .Values.fsm.gateway.infrastructure.annotations }}
name: {{ printf "fsm-gateway-%s" .Values.gwy.metadata.namespace }}
namespace: {{ .Values.gwy.metadata.namespace }}
{{- if .Values.gwy.spec.infrastructure }}
{{- with .Values.gwy.spec.infrastructure.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
labels:
{{- include "fsm.labels" . | nindent 4 }}
{{- if .Values.fsm.gateway.infrastructure }}
{{- with .Values.fsm.gateway.infrastructure.labels }}
{{- if .Values.gwy.spec.infrastructure }}
{{- with .Values.gwy.spec.infrastructure.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
app: fsm-gateway
meshName: {{ .Values.fsm.meshName }}
spec:
replicas: {{ default 1 .Values.fsm.gateway.replicas }}
replicas: {{ default 1 .Values.fsm.fsmGateway.replicas }}
selector:
matchLabels:
app: fsm-gateway
gateway.flomesh.io/ns: {{ .Values.fsm.gateway.namespace }}
gateway.flomesh.io/name: {{ .Values.fsm.gateway.name }}
gateway.flomesh.io/ns: {{ .Values.gwy.metadata.namespace }}
strategy:
rollingUpdate:
maxSurge: 1
Expand All @@ -35,24 +34,23 @@ spec:
metadata:
labels:
app: fsm-gateway
gateway.flomesh.io/ns: {{ .Values.fsm.gateway.namespace }}
gateway.flomesh.io/name: {{ .Values.fsm.gateway.name }}
{{- with .Values.fsm.gateway.podLabels }}
gateway.flomesh.io/ns: {{ .Values.gwy.metadata.namespace }}
{{- with .Values.fsm.fsmGateway.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.fsm.gateway.infrastructure }}
{{- with .Values.fsm.gateway.infrastructure.labels }}
{{- if .Values.gwy.spec.infrastructure }}
{{- with .Values.gwy.spec.infrastructure.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
annotations:
prometheus.io/scrape: 'true'
prometheus.io/port: '9091'
{{- with .Values.fsm.gateway.podAnnotations }}
{{- with .Values.fsm.fsmGateway.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.fsm.gateway.infrastructure }}
{{- with .Values.fsm.gateway.infrastructure.annotations }}
{{- if .Values.gwy.spec.infrastructure }}
{{- with .Values.gwy.spec.infrastructure.annotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
Expand All @@ -73,8 +71,8 @@ spec:
- --retry-delay
- "5"
resources:
{{- toYaml .Values.fsm.gateway.initResources | nindent 10 }}
{{- with .Values.fsm.gateway.securityContext }}
{{- toYaml .Values.fsm.fsmGateway.initResources | nindent 10 }}
{{- with .Values.fsm.fsmGateway.securityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
Expand All @@ -83,21 +81,19 @@ spec:
image: {{ include "fsmGateway.image" . }}
imagePullPolicy: {{ .Values.fsm.image.pullPolicy }}
ports:
{{- range $listener := .Values.fsm.gateway.listeners }}
{{- range $listener := .Values.listeners }}
- name: {{ $listener.name }}
containerPort: {{ ternary (add 60000 $listener.port) $listener.port (lt (int $listener.port) 1024)}}
{{- end }}
- name: health
containerPort: 8081
args:
- --verbosity={{ .Values.fsm.gateway.logLevel }}
- --verbosity={{ .Values.fsm.fsmGateway.logLevel }}
- --fsm-namespace={{ .Values.fsm.fsmNamespace }}
- --fsm-version={{ .Chart.AppVersion }}
- --mesh-name={{ .Values.fsm.meshName }}
- --gateway-namespace={{ .Values.fsm.gateway.namespace }}
- --gateway-name={{ .Values.fsm.gateway.name }}
resources:
{{- toYaml .Values.fsm.gateway.resources | nindent 10 }}
{{- toYaml .Values.fsm.fsmGateway.resources | nindent 10 }}
env:
- name: FSM_NAMESPACE
value: {{ .Values.fsm.fsmNamespace }}
Expand All @@ -109,10 +105,10 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
{{- with .Values.fsm.gateway.env }}
{{- with .Values.fsm.fsmGateway.env }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.fsm.gateway.securityContext }}
{{- with .Values.fsm.fsmGateway.securityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
Expand All @@ -127,7 +123,7 @@ spec:
tcpSocket:
port: 9091
terminationGracePeriodSeconds: 60
{{- with .Values.fsm.gateway.podSecurityContext }}
{{- with .Values.fsm.fsmGateway.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
Expand All @@ -136,7 +132,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.fsm.gateway.nodeSelector }}
{{- with .Values.fsm.fsmGateway.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -166,14 +162,10 @@ spec:
- key: gateway.flomesh.io/ns
operator: In
values:
- {{ .Values.fsm.gateway.namespace }}
- key: gateway.flomesh.io/name
operator: In
values:
- {{ .Values.fsm.gateway.name }}
- {{ .Values.gwy.metadata.namespace }}
topologyKey: kubernetes.io/hostname
weight: 100
{{- with .Values.fsm.gateway.tolerations }}
{{- with .Values.fsm.fsmGateway.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down
Loading

0 comments on commit c550d52

Please sign in to comment.