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

feat: support nacos storage #796

Draft
wants to merge 43 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
bd58388
feat: support nacos storage
sjcsjc123 Jan 22, 2024
625c61d
recover something
sjcsjc123 Jan 22, 2024
d848bb8
recover something
sjcsjc123 Jan 22, 2024
e8888cb
recover something
sjcsjc123 Jan 22, 2024
d01a220
simple
sjcsjc123 Jan 22, 2024
d8bb8d3
fix bug
sjcsjc123 Jan 23, 2024
5aed7f4
modify nacos image
sjcsjc123 Jan 23, 2024
0ffcc30
update nacos image in Makefile
sjcsjc123 Jan 23, 2024
c0c4e38
add nacos client
sjcsjc123 Jan 23, 2024
8eb8f5b
add ci for nacos storage
sjcsjc123 Jan 23, 2024
9bb4920
delete something
sjcsjc123 Jan 23, 2024
31ca385
fix bug with start fail
sjcsjc123 Jan 23, 2024
b5fd8a7
rename make
sjcsjc123 Jan 23, 2024
85b8274
opt import
sjcsjc123 Jan 23, 2024
370d386
update e2e
sjcsjc123 Jan 24, 2024
01c08fe
opt import
sjcsjc123 Jan 24, 2024
06651de
recover something
sjcsjc123 Jan 24, 2024
35c5db1
modify default falg value
sjcsjc123 Jan 24, 2024
9449862
make ci print simple
sjcsjc123 Jan 24, 2024
ecb2672
update apply
sjcsjc123 Jan 24, 2024
62c421a
update apply
sjcsjc123 Jan 24, 2024
2e72259
add wasm+nacos ci
sjcsjc123 Jan 24, 2024
0c83d5f
update wasm+nacos ci
sjcsjc123 Jan 24, 2024
0715626
fix ci
sjcsjc123 Jan 24, 2024
62cb1dd
fix bug with wasm plugin
sjcsjc123 Jan 24, 2024
8ce8df9
Merge branch 'main' into helm/nacos-storage
sjcsjc123 Jan 27, 2024
cd3527e
Merge branch 'main' into helm/nacos-storage
sjcsjc123 Jan 31, 2024
4b5cd88
fix ci
sjcsjc123 Feb 1, 2024
a3ecec7
Merge branch 'main' into helm/nacos-storage
sjcsjc123 Feb 1, 2024
9349772
fix ci
sjcsjc123 Feb 1, 2024
a3b114b
fix ci
sjcsjc123 Feb 1, 2024
41bd16a
Merge branch 'main' into helm/nacos-storage
johnlanni Feb 3, 2024
598aaf0
Merge branch 'main' into helm/nacos-storage
johnlanni Feb 20, 2024
a8af197
Merge branch 'main' into helm/nacos-storage
sjcsjc123 Feb 28, 2024
6cd64b4
update nacos image
sjcsjc123 Feb 29, 2024
5575512
update nacos image
sjcsjc123 Feb 29, 2024
81810c0
fix ci
sjcsjc123 Feb 29, 2024
daba6c7
fix ci
sjcsjc123 Feb 29, 2024
32a6786
fix ci
sjcsjc123 Mar 1, 2024
0a425dd
fix ci
sjcsjc123 Mar 1, 2024
0f270ce
Merge branch 'main' into helm/nacos-storage
sjcsjc123 Mar 27, 2024
b306f61
Merge branch 'main' into helm/nacos-storage
johnlanni Apr 1, 2024
688442b
Merge branch 'main' into helm/nacos-storage
johnlanni Apr 23, 2024
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
31 changes: 19 additions & 12 deletions Makefile.core.mk
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ install-dev: pre-install
helm install higress helm/core -n higress-system --create-namespace --set 'controller.tag=$(TAG)' --set 'gateway.replicas=1' --set 'pilot.tag=$(ISTIO_LATEST_IMAGE_TAG)' --set 'gateway.tag=$(ENVOY_LATEST_IMAGE_TAG)' --set 'global.local=true'
install-dev-wasmplugin: build-wasmplugins pre-install
helm install higress helm/core -n higress-system --create-namespace --set 'controller.tag=$(TAG)' --set 'gateway.replicas=1' --set 'pilot.tag=$(ISTIO_LATEST_IMAGE_TAG)' --set 'gateway.tag=$(ENVOY_LATEST_IMAGE_TAG)' --set 'global.local=true' --set 'global.volumeWasmPlugins=true' --set 'global.onlyPushRouteCluster=false'
install-dev-nacos: pre-install
kubectl apply -f tools/hack/conf/nacos.yaml
tools/hack/gen-keys.sh
helm install higress helm/core -n higress-system --set 'controller.tag=$(TAG)' --set 'gateway.replicas=1' --set 'pilot.tag=$(ISTIO_LATEST_IMAGE_TAG)' --set 'gateway.tag=$(ENVOY_LATEST_IMAGE_TAG)' --set 'global.local=true' --set 'apiserver.enabled=true' --set 'apiserver.serverAddr="http://nacos-service.higress-system.svc.cluster.local:8848"'

create-nacos:
kubectl apply -f tools/hack/conf/nacos.yaml

uninstall:
helm uninstall higress -n higress-system
Expand Down Expand Up @@ -258,18 +265,18 @@ delete-cluster: $(tools/kind) ## Delete kind cluster.
.PHONY: kube-load-image
kube-load-image: $(tools/kind) ## Install the Higress image to a kind cluster using the provided $IMAGE and $TAG.
tools/hack/kind-load-image.sh higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/higress $(TAG)
tools/hack/docker-pull-image.sh higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/dubbo-provider-demo 0.0.3-x86
tools/hack/docker-pull-image.sh docker.io/alihigress/nacos-standlone-rc3 1.0.0-RC3
tools/hack/docker-pull-image.sh docker.io/hashicorp/consul 1.16.0
tools/hack/docker-pull-image.sh docker.io/charlie1380/eureka-registry-provider v0.3.0
tools/hack/docker-pull-image.sh docker.io/bitinit/eureka latest
tools/hack/docker-pull-image.sh docker.io/alihigress/httpbin 1.0.2
tools/hack/kind-load-image.sh higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/dubbo-provider-demo 0.0.3-x86
tools/hack/kind-load-image.sh docker.io/alihigress/nacos-standlone-rc3 1.0.0-RC3
tools/hack/kind-load-image.sh docker.io/hashicorp/consul 1.16.0
tools/hack/kind-load-image.sh docker.io/alihigress/httpbin 1.0.2
tools/hack/kind-load-image.sh docker.io/charlie1380/eureka-registry-provider v0.3.0
tools/hack/kind-load-image.sh docker.io/bitinit/eureka latest
#tools/hack/docker-pull-image.sh higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/dubbo-provider-demo 0.0.3-x86
sjcsjc123 marked this conversation as resolved.
Show resolved Hide resolved
#tools/hack/docker-pull-image.sh docker.io/alihigress/nacos-standlone-rc3 1.0.0-RC3
#tools/hack/docker-pull-image.sh docker.io/hashicorp/consul 1.16.0
#tools/hack/docker-pull-image.sh docker.io/charlie1380/eureka-registry-provider v0.3.0
#tools/hack/docker-pull-image.sh docker.io/bitinit/eureka latest
#tools/hack/docker-pull-image.sh docker.io/alihigress/httpbin 1.0.2
#tools/hack/kind-load-image.sh higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/dubbo-provider-demo 0.0.3-x86
#tools/hack/kind-load-image.sh docker.io/alihigress/nacos-standlone-rc3 1.0.0-RC3
#tools/hack/kind-load-image.sh docker.io/hashicorp/consul 1.16.0
#tools/hack/kind-load-image.sh docker.io/alihigress/httpbin 1.0.2
#tools/hack/kind-load-image.sh docker.io/charlie1380/eureka-registry-provider v0.3.0
#tools/hack/kind-load-image.sh docker.io/bitinit/eureka latest
# run-higress-e2e-test starts to run ingress e2e tests.
.PHONY: run-higress-e2e-test
run-higress-e2e-test:
Expand Down
7 changes: 6 additions & 1 deletion docker/Dockerfile.higress
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ FROM ${HUB}/base:${BASE_VERSION}
ARG TARGETARCH

COPY ${TARGETARCH:-amd64}/higress /usr/local/bin/higress
COPY wait-for-apiserver.sh /usr/local/bin/wait-for-apiserver.sh
COPY run-higress.sh /usr/local/bin/run-higress.sh

RUN chmod +x /usr/local/bin/wait-for-apiserver.sh
RUN chmod +x /usr/local/bin/run-higress.sh
sjcsjc123 marked this conversation as resolved.
Show resolved Hide resolved

USER 1337:1337

ENTRYPOINT ["/usr/local/bin/higress"]
ENTRYPOINT ["/usr/local/bin/run-higress.sh"]
4 changes: 4 additions & 0 deletions docker/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@

docker.higress: BUILD_ARGS=--build-arg BASE_VERSION=${BASE_VERSION} --build-arg HUB=${HUB}
docker.higress: $(OUT_LINUX)/higress
docker.higress: docker/wait-for-apiserver.sh
docker.higress: docker/run-higress.sh
docker.higress: docker/Dockerfile.higress
$(HIGRESS_DOCKER_RULE)

docker.higress-buildx: BUILD_ARGS=--build-arg BASE_VERSION=${BASE_VERSION} --build-arg HUB=${HUB}
docker.higress-buildx: $(AMD64_OUT_LINUX)/higress
docker.higress-buildx: $(ARM64_OUT_LINUX)/higress
docker.higress: docker/wait-for-apiserver.sh
docker.higress: docker/run-higress.sh
docker.higress-buildx: docker/Dockerfile.higress
$(HIGRESS_DOCKER_BUILDX_RULE)

Expand Down
29 changes: 29 additions & 0 deletions docker/run-higress.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Copyright (c) 2022 Alibaba Group Holding Ltd.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http:www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

args=("$@")

for arg in "${args[@]}"; do
echo "Argument: $arg"
done

/usr/local/bin/wait-for-apiserver.sh

echo "starting higress..."

/usr/local/bin/higress "$@"
sjcsjc123 marked this conversation as resolved.
Show resolved Hide resolved

echo "higress started."
27 changes: 27 additions & 0 deletions docker/wait-for-apiserver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Copyright (c) 2022 Alibaba Group Holding Ltd.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http:www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# if has HIGRESS_APISERVER_SVC env, wait for apiserver ready
if [ -n "$HIGRESS_APISERVER_SVC" ]; then
while true; do
echo "testing higress apiserver is ready to connect..."
nc -z "$HIGRESS_APISERVER_SVC" "${HIGRESS_APISERVER_PORT}"
if [ $? -eq 0 ]; then
break
fi
sleep 1
done
fi
4 changes: 4 additions & 0 deletions helm/core/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,7 @@ higress: {{ include "controller.name" . }}
true
{{- end }}
{{- end }}

{{- define "apiserver.name" -}}
{{- .Values.apiserver.name | default "higress-apiserver" -}}
{{- end }}
23 changes: 22 additions & 1 deletion helm/core/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,28 @@ metadata:
labels:
{{- include "gateway.labels" . | nindent 4 }}
data:

{{- if .Values.apiserver.enabled }}
kubeconfig: |
apiVersion: v1
kind: Config
clusters:
- name: {{ .Release.Namespace }}
cluster:
server: https://{{ .Values.apiserver.addr }}:{{ .Values.apiserver.securePort }}
insecure-skip-tls-verify: true
users:
- name: higress-admin
user:
client-certificate-data: {{ .Files.Get "files/api/client.crt" | b64enc }}
client-key-data: {{ .Files.Get "files/api/client.key" | b64enc }}
contexts:
- name: higress
context:
cluster: higress
user: higress-admin
preferences: {}
current-context: higress
{{- end }}
# Configuration file for the mesh networks to be used by the Split Horizon EDS.
meshNetworks: |-
{{- if .Values.global.meshNetworks }}
Expand Down
107 changes: 107 additions & 0 deletions helm/core/templates/controller-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ spec:
image: "{{ .Values.controller.hub | default .Values.global.hub }}/{{ .Values.controller.image | default "higress" }}:{{ .Values.controller.tag | default .Chart.AppVersion }}"
args:
- "serve"
{{- if .Values.apiserver.enabled }}
- --kubeconfig=/etc/istio/config/kubeconfig
{{- end }}
- --gatewaySelectorKey=higress
- --gatewaySelectorValue={{ .Release.Namespace }}-{{ include "gateway.name" . }}
{{- if not .Values.global.enableStatus }}
Expand All @@ -199,6 +202,12 @@ spec:
- --watchNamespace={{ .Values.global.watchNamespace }}
{{- end }}
env:
{{- if .Values.apiserver.enabled }}
- name: HIGRESS_APISERVER_SVC
value: {{ .Values.apiserver.addr | quote }}
- name: HIGRESS_APISERVER_PORT
value: {{ .Values.apiserver.securePort | quote }}
{{- end }}
- name: POD_NAME
valueFrom:
fieldRef:
Expand Down Expand Up @@ -237,6 +246,96 @@ spec:
volumeMounts:
- name: log
mountPath: /var/log
{{- if .Values.apiserver.enabled }}
- name: config
mountPath: /etc/istio/config
{{- end }}
{{- if .Values.apiserver.enabled }}
- name: {{ .Values.apiserver.name }}
image: "{{ .Values.apiserver.hub | default .Values.global.hub }}/{{ .Values.apiserver.image }}:{{ .Values.apiserver.tag }}"
imagePullPolicy: {{ .Values.apiserver.imagePullPolicy }}
args:
- --secure-port
- {{ .Values.apiserver.securePort | quote }}
- --client-ca-file
- /etc/api/ca.crt
- --tls-cert-file
- /etc/api/server.crt
- --tls-private-key-file
- /etc/api/server.key
- --storage
- {{ .Values.apiserver.storage }}
- --{{ .Values.apiserver.storage }}-server
- {{ .Values.apiserver.serverAddr }}
- --{{ .Values.apiserver.storage }}-username
- {{ .Values.apiserver.username }}
- --{{ .Values.apiserver.storage }}-password
- {{ .Values.apiserver.password }}
- --{{ .Values.apiserver.storage }}-ns-id
- {{ .Values.apiserver.namespaceID }}
- --{{ .Values.apiserver.storage }}-encryption-key-file
- /etc/api/nacos.key
Copy link
Collaborator

Choose a reason for hiding this comment

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

storage 如果不是 nacos 的话,是没有以上这些参数的。这里是否要考虑开闭原则?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

不太清楚开闭原则在这里的用法,有什么改进的建议吗

env:
- name: NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: INSTANCE_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: HOST_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.hostIP
ports:
- containerPort: 8443
hostPort: 8443
name: https
protocol: TCP
readinessProbe:
failureThreshold: 30
httpGet:
path: /readyz
port: 8443
scheme: HTTPS
initialDelaySeconds: 1
periodSeconds: 2
successThreshold: 1
timeoutSeconds: 3
resources: { }
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: true
runAsGroup: 1337
runAsNonRoot: true
runAsUser: 1337
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /etc/api
name: cert-config
readOnly: true
- mountPath: /tmp/nacos
name: nacos-data
Copy link
Collaborator

Choose a reason for hiding this comment

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

下面叫{{ .Values.apiserver.storage }}-data,这里是nacos-data。同样建议考虑一下开闭原则。

{{- end }}
{{- with .Values.controller.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand All @@ -252,6 +351,14 @@ spec:
volumes:
- name: log
emptyDir: {}
{{- if .Values.apiserver.enabled }}
- name: {{ .Values.apiserver.storage }}-data
emptyDir: {}
- name: cert-config
secret:
defaultMode: 420
secretName: higress-apiserver
{{- end }}
{{- if not .Values.global.enableHigressIstio }}
- name: config
configMap:
Expand Down
16 changes: 16 additions & 0 deletions helm/core/templates/controller-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.apiserver.enabled }}
apiVersion: v1
kind: Secret
metadata:
annotations:
helm.sh/hook: pre-install,pre-upgrade
name: {{ include "apiserver.name" . }}
namespace: {{ .Release.Namespace }}
data:
ca.crt: {{ .Files.Get "files/api/ca.crt" | b64enc }}
ca.key: {{ .Files.Get "files/api/ca.key" | b64enc }}
server.crt: {{ .Files.Get "files/api/server.crt" | b64enc }}
server.key: {{ .Files.Get "files/api/server.key" | b64enc }}
client.key: {{ .Files.Get "files/api/client.crt" | b64enc }}
nacos.key: {{ .Files.Get "files/api/nacos.key" | b64enc }}
{{- end }}
8 changes: 7 additions & 1 deletion helm/core/templates/controller-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ spec:
- port: 15014
name: http-monitoring # prometheus stats
protocol: TCP
{{- if .Values.apiserver.enabled }}
- port: {{ .Values.apiserver.securePort }}
name: https-apiserver # mTLS with k8s-signed cert
sjcsjc123 marked this conversation as resolved.
Show resolved Hide resolved
protocol: TCP
targetPort: {{ .Values.apiserver.securePort }}
{{- end }}
{{- end }}
selector:
{{- include "controller.selectorLabels" . | nindent 4 }}
{{- include "controller.selectorLabels" . | nindent 4 }}
18 changes: 18 additions & 0 deletions helm/core/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,24 @@ pilot:
# Additional labels to apply on the pod level for monitoring and logging configuration.
podLabels: {}

## Higress ApiServer Storage Settings
## Todo simplify this
apiserver:
addr: 127.0.0.1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would we allow user to use another address here?

Copy link
Collaborator Author

@sjcsjc123 sjcsjc123 Jan 22, 2024

Choose a reason for hiding this comment

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

If run api server in other pod, we can modify this. If not, we can remove it. It can be fixed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

按照目前的安装方式来看,是否需要移除这个配置,把apiserver固定为higress-controller的其中一个container

enabled: false
name: "higress-apiserver"
hub: higress-registry.cn-hangzhou.cr.aliyuncs.com/higress
tag: 0.0.10
image: api-server
imagePullPolicy: IfNotPresent
securePort: 8443
storage: nacos
serverAddr: http://127.0.0.1:8848
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible that we have a Nacos running in http://127.0.0.1:8848?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This parameter is used to enable users to specify a nacos address.

Copy link
Collaborator

Choose a reason for hiding this comment

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

这个默认值如果用户不修改的话,安装肯定会失败吧?具体表现是什么?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

新增helm参数来控制是否替用户安装nacos,这个地址就修改为替用户安装nacos的时候的nacos地址,这样可以吗

username: ""
password: ""
namespaceID: ""
rsaKeyLength: 4096
serviceName: "higress-controller"
sjcsjc123 marked this conversation as resolved.
Show resolved Hide resolved

# Skywalking config settings
skywalking:
Expand Down
Loading
Loading