Skip to content

Commit a097dac

Browse files
authored
refactor:移除istio/proxyv2使用 (#140)
1 parent cc21151 commit a097dac

File tree

20 files changed

+187
-135
lines changed

20 files changed

+187
-135
lines changed

.github/workflows/docker.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ jobs:
4747
env:
4848
DOCKER_TAG: ${{ steps.get_version.outputs.VERSION }}
4949
run: |
50+
go mod tidy
5051
make all ORG=polarismesh REPO=polaris-controller IMAGE_TAG=${DOCKER_TAG}

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@ build-envoy-sidecar-init:
4343
push-image:
4444
docker push $(REGISTRY)$(ORG)/$(SIDECAR_INIT_REPO):$(IMAGE_TAG)
4545
docker push $(REGISTRY)$(ORG)/$(ENVOY_SIDECAR_INIT_REPO):$(IMAGE_TAG)
46+
47+
.PHONY: clean
48+
clean:
49+
rm -rf bin
50+
rm -rf polaris-controller-release*
51+

build.sh

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
set -e
1818

1919
if [ $# -gt 0 ]; then
20-
version="$1"
20+
version="$1"
2121
else
22-
current=$(date "+%Y-%m-%d %H:%M:%S")
23-
timeStamp=$(date -d "$current" +%s)
24-
currentTimeStamp=$(((timeStamp * 1000 + 10#$(date "+%N") / 1000000) / 1000))
25-
version="$currentTimeStamp"
22+
current=$(date "+%Y-%m-%d %H:%M:%S")
23+
timeStamp=$(date -d "$current" +%s)
24+
currentTimeStamp=$(((timeStamp * 1000 + 10#$(date "+%N") / 1000000) / 1000))
25+
version="$currentTimeStamp"
2626
fi
2727
workdir=$(dirname $(realpath $0))
2828

@@ -32,6 +32,22 @@ cat "$workdir"/deploy/variables.txt
3232
folder_name="polaris-controller-release_${version}.k8s1.21"
3333
pkg_name="${folder_name}.zip"
3434

35+
function replaceVar() {
36+
for file in $(ls *.yaml); do
37+
key="#$1#"
38+
echo "process replace file $file, key $key, value $2"
39+
if [ "$(uname)" == "Darwin" ]; then
40+
sed -i "" "s?$key?$2?g" $file
41+
else
42+
sed -i "s?$key?$2?g" $file
43+
fi
44+
done
45+
}
46+
47+
cd $workdir
48+
49+
export -f replaceVar
50+
3551
cd $workdir
3652

3753
# 清理环境
@@ -40,15 +56,26 @@ rm -f "${pkg_name}"
4056

4157
# 打包
4258
mkdir -p ${folder_name}
59+
4360
cp -r deploy/kubernetes_v1.21/* ${folder_name}
4461
cp deploy/variables.txt ${folder_name}
62+
63+
cd ${folder_name}/helm
64+
varFile="../variables.txt"
65+
if [ ! -f "$varFile" ]; then
66+
echo "variables.txt not exists"
67+
exit 1
68+
fi
69+
cat $varFile | awk -F ':' '{print "replaceVar", $1, $2 | "/bin/bash"}'
70+
71+
cd $workdir
4572
zip -r "${pkg_name}" ${folder_name}
4673
#md5sum ${pkg_name} > "${pkg_name}.md5sum"
4774

4875
if [[ $(uname -a | grep "Darwin" | wc -l) -eq 1 ]]; then
49-
md5 ${pkg_name} >"${pkg_name}.md5sum"
76+
md5 ${pkg_name} >"${pkg_name}.md5sum"
5077
else
51-
md5sum ${pkg_name} >"${pkg_name}.md5sum"
78+
md5sum ${pkg_name} >"${pkg_name}.md5sum"
5279
fi
5380

5481
folder_name="polaris-controller-release_${version}.k8s1.22"
@@ -62,13 +89,23 @@ rm -f "${pkg_name}"
6289

6390
# 打包
6491
mkdir -p ${folder_name}
92+
6593
cp -r deploy/kubernetes_v1.22/* ${folder_name}
6694
cp deploy/variables.txt ${folder_name}
95+
96+
cd ${folder_name}/helm
97+
varFile="../variables.txt"
98+
if [ ! -f "$varFile" ]; then
99+
echo "variables.txt not exists"
100+
exit 1
101+
fi
102+
cat $varFile | awk -F ':' '{print "replaceVar", $1, $2 | "/bin/bash"}'
103+
cd $workdir
67104
zip -r "${pkg_name}" ${folder_name}
68105
#md5sum ${pkg_name} > "${pkg_name}.md5sum"
69106

70107
if [[ $(uname -a | grep "Darwin" | wc -l) -eq 1 ]]; then
71-
md5 ${pkg_name} >"${pkg_name}.md5sum"
108+
md5 ${pkg_name} >"${pkg_name}.md5sum"
72109
else
73-
md5sum ${pkg_name} >"${pkg_name}.md5sum"
110+
md5sum ${pkg_name} >"${pkg_name}.md5sum"
74111
fi

deploy/kubernetes_v1.21/helm/templates/_helpers.tpl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@ Get specific image for sidecar init container
4141
{{- printf "%s:%s" .Values.sidecar.init.image.repo .Values.sidecar.init.image.tag -}}
4242
{{- end -}}
4343

44+
{{/*
45+
Get specific image for sidecar init container
46+
*/}}
47+
{{- define "polaris-controller.sidecar.envoy_init.image" -}}
48+
{{- printf "%s:%s" .Values.sidecar.envoy_builder.image.repo .Values.sidecar.envoy_builder.image.tag -}}
49+
{{- end -}}
50+
51+
{{/*
52+
Get specific image for sidecar init container
53+
*/}}
54+
{{- define "polaris-controller.sidecar.envoy.image" -}}
55+
{{- printf "%s:%s" .Values.sidecar.envoy.image.repo .Values.sidecar.envoy.image.tag -}}
56+
{{- end -}}
57+
58+
{{/*
59+
Get specific image for sidecar init container
60+
*/}}
61+
{{- define "polaris-controller.sidecar.istio.image" -}}
62+
{{- printf "%s:%s" .Values.sidecar.istio.image.repo .Values.sidecar.istio.image.tag -}}
63+
{{- end -}}
4464

4565
{{/*
4666
Create a default fully qualified controller name.

deploy/kubernetes_v1.21/helm/templates/_params.tpl

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,6 @@ Define the volume mounts for the sidecar container.
3232
{{ "{{" }} end {{ "}}" }}
3333
{{- end -}}
3434

35-
36-
{{/*
37-
Define the cmd args for the bootstrap init container.
38-
*/}}
39-
{{- define "configmap-sidecar.bootstrap_args" -}}
40-
- istio-iptables
41-
- -p
42-
- "15001"
43-
- -z
44-
- "15006"
45-
- -u
46-
- "1337"
47-
- -m
48-
- REDIRECT
49-
- -i
50-
- "10.4.4.4/32"
51-
- -b
52-
- "{{ "{{" }} (annotation .ObjectMeta `polarismesh.cn/includeInboundPorts` `*`) {{ "}}" }}"
53-
- -x
54-
- "{{ "{{" }} (annotation .ObjectMeta `polarismesh.cn/excludeOutboundCIDRs` ``) {{ "}}" }}"
55-
- -d
56-
- "{{ "{{" }} (annotation .ObjectMeta `polarismesh.cn/excludeInboundPorts` ``) {{ "}}" }}"
57-
- -o
58-
- "{{ "{{" }} (annotation .ObjectMeta `polarismesh.cn/excludeOutboundPorts` ``) {{ "}}" }}"
59-
- --redirect-dns=true
60-
{{- end -}}
61-
62-
6335
{{/*
6436
Define the volume for the bootstrap init container.
6537
*/}}

deploy/kubernetes_v1.21/helm/templates/controller-configmap-sidecar.yaml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ data:
9898
template: |
9999
containers:
100100
- name: envoy
101-
securityContext:
102-
runAsUser: 1337
103-
runAsGroup: 1337
104-
image: {{ .Values.sidecar.envoy.image.repo }}:{{ .Values.sidecar.envoy.image.tag }}
101+
image: {{ include "polaris-controller.sidecar.envoy.image" . }}
105102
imagePullPolicy: Always
106103
command: ["/usr/local/bin/envoy"]
107104
args: ["-c", "/etc/envoy/envoy.yaml", "--log-path", "/etc/envoy_logs/envoy.log"]
@@ -136,7 +133,7 @@ data:
136133
{{ include "configmap-sidecar.polaris_volume_mounts" . | nindent 10 }}
137134
initContainers:
138135
- name: polaris-bootstrap-writer
139-
image: polarismesh/polaris-envoy-bootstrap-generator:v1.3.0-beta.1
136+
image: {{ include "polaris-controller.sidecar.envoy_init.image" . }}
140137
imagePullPolicy: Always
141138
env:
142139
{{ include "configmap-sidecar.bootstrap_envs" . | nindent 10 }}
@@ -145,11 +142,13 @@ data:
145142
name: envoy-bootstrap
146143
- mountPath: /data/polaris-client-config
147144
name: polaris-client-config
148-
- name: istio-init
149-
image: istio/proxyv2:1.18.0-debug
150-
imagePullPolicy: IfNotPresent
151-
args:
152-
{{ include "configmap-sidecar.bootstrap_args" . | nindent 10 }}
145+
- name: polaris-sidecar-init
146+
image: {{ include "polaris-controller.sidecar.init.image" . }}
147+
imagePullPolicy: Always
148+
command: ["./start.sh"]
149+
env:
150+
- name: RUN_MODE
151+
value: MESH
153152
resources:
154153
limits:
155154
cpu: 100m
@@ -170,5 +169,17 @@ data:
170169
runAsGroup: 0
171170
runAsNonRoot: false
172171
runAsUser: 0
172+
volumeMounts:
173+
- mountPath: /data/polaris-client-config
174+
name: polaris-client-config
173175
volumes:
174-
{{ include "configmap-sidecar.bootstrap_args" . | nindent 8 }}
176+
- name: polaris-client-config
177+
emptyDir: {}
178+
- name: envoy-bootstrap
179+
emptyDir: {}
180+
- name: envoy-logs
181+
emptyDir: {}
182+
- name: polaris-dir
183+
emptyDir: {}
184+
- name: polaris-log
185+
emptyDir: {}

deploy/kubernetes_v1.21/helm/values.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,27 @@ sidecar:
1616
mode: mesh
1717
image:
1818
repo: polarismesh/polaris-sidecar
19-
tag: v1.4.0
19+
tag: #SIDECAR_VERSION#
2020
pullPolicy: Always
2121
init:
2222
image:
2323
repo: polarismesh/polaris-sidecar-init
24-
tag: v1.4.0
24+
tag: #CONTROLLER_VERSION#
2525
pullPolicy: Always
2626
envoy:
2727
image:
2828
repo: envoyproxy/envoy
29-
tag: v1.21.6
29+
tag: #ENVOY_VERSION#
30+
envoy_builder:
31+
image:
32+
repo: polarismesh/polaris-envoy-bootstrap-generator
33+
tag: #CONTROLLER_VERSION#
3034

3135
## polaris server config
3236
polaris:
3337
server:
34-
address: localhost
35-
token: nu/0WRA4EqSR1FagrjRj0fZwPXuGlMpX+zCuWu4uMqy8xr1vRjisSbA25aAC3mtU8MeeRsKhQiDAynUR09I=
38+
address: #POLARIS_HOST#
39+
token: #POLARIS_TOKEN#
3640

3741
## polaris controller config
3842
controller:
@@ -42,7 +46,7 @@ controller:
4246
service: polaris-sidecar-injector
4347
image:
4448
repo: polarismesh/polaris-controller
45-
tag: v1.4.0-beta.0
49+
tag: #CONTROLLER_VERSION#
4650
pullPolicy: IfNotPresent
4751
metrics:
4852
port: 80

deploy/kubernetes_v1.21/injector.yaml

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ data:
118118
template: |+
119119
containers:
120120
- name: envoy
121-
securityContext:
122-
runAsUser: 1337
123-
runAsGroup: 1337
124121
image: envoyproxy/envoy:#ENVOY_VERSION#
125122
imagePullPolicy: Always
126123
command: ["/usr/local/bin/envoy"]
@@ -218,30 +215,13 @@ data:
218215
name: envoy-bootstrap
219216
- mountPath: /data/polaris-client-config
220217
name: polaris-client-config
221-
- name: istio-init
222-
image: istio/proxyv2:1.18.0-debug
223-
imagePullPolicy: IfNotPresent
224-
args:
225-
- istio-iptables
226-
- -p
227-
- "15001"
228-
- -z
229-
- "15006"
230-
- -u
231-
- "1337"
232-
- -m
233-
- REDIRECT
234-
- -i
235-
- "10.4.4.4/32"
236-
- -b
237-
- "{{ (annotation .ObjectMeta `polarismesh.cn/includeInboundPorts` `*`) }}"
238-
- -x
239-
- "{{ (annotation .ObjectMeta `polarismesh.cn/excludeOutboundCIDRs` ``) }}"
240-
- -d
241-
- "{{ (annotation .ObjectMeta `polarismesh.cn/excludeInboundPorts` `15985,50000`) }}"
242-
- -o
243-
- "{{ (annotation .ObjectMeta `polarismesh.cn/excludeOutboundPorts` ``) }}"
244-
- --redirect-dns=true
218+
- name: polaris-sidecar-init
219+
image: polarismesh/polaris-sidecar-init:#CONTROLLER_VERSION#
220+
imagePullPolicy: Always
221+
command: ["./start.sh"]
222+
env:
223+
- name: RUN_MODE
224+
value: MESH
245225
resources:
246226
limits:
247227
cpu: 100m
@@ -262,6 +242,9 @@ data:
262242
runAsGroup: 0
263243
runAsNonRoot: false
264244
runAsUser: 0
245+
volumeMounts:
246+
- mountPath: /data/polaris-client-config
247+
name: polaris-client-config
265248
volumes:
266249
- name: sds
267250
emptyDir: {}

deploy/kubernetes_v1.22/helm/templates/_helpers.tpl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,28 @@ Get specific image for sidecar init container
4141
{{- printf "%s:%s" .Values.sidecar.init.image.repo .Values.sidecar.init.image.tag -}}
4242
{{- end -}}
4343

44+
{{/*
45+
Get specific image for sidecar init container
46+
*/}}
47+
{{- define "polaris-controller.sidecar.envoy.image" -}}
48+
{{- printf "%s:%s" .Values.sidecar.envoy.image.repo .Values.sidecar.envoy.image.tag -}}
49+
{{- end -}}
50+
51+
52+
{{/*
53+
Get specific image for sidecar init container
54+
*/}}
55+
{{- define "polaris-controller.sidecar.envoy_init.image" -}}
56+
{{- printf "%s:%s" .Values.sidecar.envoy_builder.image.repo .Values.sidecar.envoy_builder.image.tag -}}
57+
{{- end -}}
58+
59+
{{/*
60+
Get specific image for sidecar init container
61+
*/}}
62+
{{- define "polaris-controller.sidecar.istio.image" -}}
63+
{{- printf "%s:%s" .Values.sidecar.istio.image.repo .Values.sidecar.istio.image.tag -}}
64+
{{- end -}}
65+
4466

4567
{{/*
4668
Create a default fully qualified controller name.

deploy/kubernetes_v1.22/helm/templates/_params.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Define the cmd args for the bootstrap init container.
4040
- -x
4141
- "{{ "{{" }} (annotation .ObjectMeta `polarismesh.cn/excludeOutboundCIDRs` ``) {{ "}}" }}"
4242
- -d
43-
- "{{ "{{" }} (annotation .ObjectMeta `polarismesh.cn/excludeInboundPorts` ``) {{ "}}" }}"
43+
- "{{ "{{" }} (annotation .ObjectMeta `polarismesh.cn/excludeInboundPorts` `15985,50000,15053`) {{ "}}" }}"
4444
- -o
4545
- "{{ "{{" }} (annotation .ObjectMeta `polarismesh.cn/excludeOutboundPorts` ``) {{ "}}" }}"
4646
- --redirect-dns=true

0 commit comments

Comments
 (0)