Skip to content

Commit

Permalink
fix:sync instance version not set (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun authored Jan 4, 2024
1 parent 7cc9762 commit 8c40f28
Show file tree
Hide file tree
Showing 38 changed files with 286 additions and 236 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ build-multi-arch-image:
@echo "------------------"
@echo "--> Building multi-arch docker image for polaris-controller"
@echo "------------------"
@docker buildx build --platform $(PLATFORMS) --tag $(ORG)/$(REPO):$(IMAGE_TAG) -f ./docker/Dockerfile --push ./
@docker buildx build -f ./docker/Dockerfile --tag $(ORG)/$(REPO):$(IMAGE_TAG) --platform $(PLATFORMS) --push ./

.PHONY: build-sidecar-init
build-sidecar-init:
Expand Down
18 changes: 11 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ workdir=$(dirname $(realpath $0))
sed -i "s/##VERSION##/$version/g" "$workdir"/deploy/variables.txt
cat "$workdir"/deploy/variables.txt

folder_name="polaris-controller-release_${version}.k8s1.21"
pkg_name="${folder_name}.zip"

function replaceVar() {
for file in $(ls *.yaml); do
key="#$1#"
Expand All @@ -48,6 +45,11 @@ cd $workdir

export -f replaceVar

# 处理 kubernetes <= 1.21 的 polaris-controller 发布包

folder_name="polaris-controller-release_${version}.k8s1.21"
pkg_name="${folder_name}.zip"

cd $workdir

# 清理环境
Expand All @@ -58,10 +60,10 @@ rm -f "${pkg_name}"
mkdir -p ${folder_name}

cp -r deploy/kubernetes_v1.21/* ${folder_name}
cp deploy/variables.txt ${folder_name}
cp deploy/variables.txt ${folder_name}/kubernetes

cd ${folder_name}/helm
varFile="../variables.txt"
varFile="../kubernetes/variables.txt"
if [ ! -f "$varFile" ]; then
echo "variables.txt not exists"
exit 1
Expand All @@ -78,6 +80,8 @@ else
md5sum ${pkg_name} >"${pkg_name}.md5sum"
fi

# 处理 kubernetes >= 1.22 的 polaris-controller 发布包

folder_name="polaris-controller-release_${version}.k8s1.22"
pkg_name="${folder_name}.zip"

Expand All @@ -91,10 +95,10 @@ rm -f "${pkg_name}"
mkdir -p ${folder_name}

cp -r deploy/kubernetes_v1.22/* ${folder_name}
cp deploy/variables.txt ${folder_name}
cp deploy/variables.txt ${folder_name}/kubernetes

cd ${folder_name}/helm
varFile="../variables.txt"
varFile="../kubernetes/variables.txt"
if [ ! -f "$varFile" ]; then
echo "variables.txt not exists"
exit 1
Expand Down
3 changes: 3 additions & 0 deletions cmd/polaris-controller/app/polaris-controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ func buildAPI() (api.ConsumerAPI, api.ProviderAPI, error) {
cfg.GetGlobal().GetServerConnector().SetConnectTimeout(time.Second * 10)
cfg.GetGlobal().GetServerConnector().SetMessageTimeout(time.Second * 10)
cfg.GetGlobal().GetAPI().SetTimeout(time.Second * 10)
cfg.GetConfigFile().GetConfigConnectorConfig().SetAddresses([]string{polarisapi.PolarisConfigGrpc})
cfg.GetConfigFile().GetConfigConnectorConfig().SetConnectTimeout(time.Second * 10)
cfg.GetConfigFile().GetConfigConnectorConfig().SetMessageTimeout(time.Second * 10)

consumerAPI, err := api.NewConsumerAPIByConfig(cfg)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ rules:
resources:
- services
- namespaces
- configmaps
- pods
- endpoints
verbs:
- get
- list
Expand All @@ -18,7 +18,7 @@ rules:
- ""
resources:
- events
- endpoints
- configmaps
verbs:
- create
- update
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ spec:
fieldPath: metadata.namespace
imagePullPolicy: Always
volumeMounts:
- mountPath: /polaris-controller/log
name: log
- mountPath: /polaris-controller/logs
name: logs
- name: certs
mountPath: /etc/polaris-inject/certs
readOnly: true
Expand Down Expand Up @@ -72,6 +72,6 @@ spec:
configMap:
name: injector-mesh
- hostPath:
path: /data/polaris-controller/log
path: /data/polaris-controller/logs
type: "DirectoryOrCreate"
name: log
name: logs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ rules:
- namespaces
- configmaps
- pods
- endpoints
verbs:
- get
- list
Expand All @@ -25,7 +26,7 @@ rules:
- ""
resources:
- events
- endpoints
- configmaps
verbs:
- create
- update
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ rules:
resources:
- services
- namespaces
- configmaps
- pods
- endpoints
verbs:
- get
- list
Expand All @@ -18,7 +18,7 @@ rules:
- ""
resources:
- events
- endpoints
- configmaps
verbs:
- create
- update
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: injector-mesh
name: polaris-controller-config
namespace: polaris-system
data:
mesh: |-
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: polaris-sidecar-injector
namespace: polaris-system
labels:
app: sidecar-injector
spec:
minAvailable: 1
selector:
matchLabels:
app: sidecar-injector

---
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down Expand Up @@ -254,45 +239,3 @@ data:
emptyDir: {}
- name: polaris-log
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: polaris-sidecar-injector
namespace: polaris-system
labels:
app: sidecar-injector
spec:
ports:
- port: 443
targetPort: 9443
selector:
app: sidecar-injector
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: polaris-sidecar-injector
labels:
app: sidecar-injector
webhooks:
- name: polaris.tencent.com
clientConfig:
service:
name: polaris-sidecar-injector
namespace: polaris-system
path: "/inject"
caBundle: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUZpVENDQTNHZ0F3SUJBZ0lVSUJGZmZMeE84K2RNSTNrd3hOcXpibGg4Z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L2szV0IrTmlZbU94QzJ5SjRvMWRtYnZvS2ZadGIxVVBObVRJcmxXNThlMDdmUGV4QmNwR3JSRk5yVS9kaQpJbEpMNytXVVBKQWluTC8zL0FLQm5md1ZaemtrOVlUdld0b2xZeElhRExTd3JsdEdvZjBQUkptYnI0UDdxbm56ClFDUXVlZDFsUjRaUHJnYUlnZEdHSjdac1lESlVZbS8xd2g3N3FmR3FlYlRFZmorV09JYzV2S09vcEZTY0ZXd3oKNGVZVmVMYjBZdkc0dmc3ZHhCNFArbElzaFNpdmRVUE5XMW5ZY05pcFIrNnI2Q3h0ZnIwWjZWSkFjZjdTR1FHNwpYZkNuQXdMdlJtMEs2Q1Z6WUhPTFVRR2ZVSjBEbGFEeUR3c0JOc009Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
rules:
- operations: ["CREATE"]
apiGroups: [""]
apiVersions: ["v1"]
resources: ["pods"]
admissionReviewVersions: ["v1"]
sideEffects: "None"
failurePolicy: Fail
namespaceSelector:
matchLabels:
polaris-injection: enabled
---

File renamed without changes.
File renamed without changes.
133 changes: 133 additions & 0 deletions deploy/kubernetes_v1.22/kubernetes/polaris-controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: polaris-sidecar-injector
namespace: polaris-system
labels:
app: sidecar-injector
spec:
minAvailable: 1
selector:
matchLabels:
app: sidecar-injector
---
apiVersion: v1
kind: Service
metadata:
name: polaris-sidecar-injector
namespace: polaris-system
labels:
app: sidecar-injector
spec:
ports:
- port: 443
targetPort: 9443
selector:
app: sidecar-injector
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: polaris-sidecar-injector
labels:
app: sidecar-injector
webhooks:
- name: polaris.tencent.com
clientConfig:
service:
name: polaris-sidecar-injector
namespace: polaris-system
path: "/inject"
caBundle: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUZpVEND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ZDdURWbkg0VHVqb2swU1RXdUlWUDM5c21DUE5kUElwUVIxblIKSnZ1L2szV0IrTmlZbU94QzJ5SjRvMWRtYnZvS2ZadGIxVVBObVRJcmxXNThlMDdmUGV4QmNwR3JSRk5yVS9kaQpJbEpMNytXVVBKQWluTC8zL0FLQm5md1ZaemtrOVlUdld0b2xZeElhRExTd3JsdEdvZjBQUkptYnI0UDdxbm56ClFDUXVlZDFsUjRaUHJnYUlnZEdHSjdac1lESlVZbS8xd2g3N3FmR3FlYlRFZmorV09JYzV2S09vcEZTY0ZXd3oKNGVZVmVMYjBZdkc0dmc3ZHhCNFArbElzaFNpdmRVUE5XMW5ZY05pcFIrNnI2Q3h0ZnIwWjZWSkFjZjdTR1FHNwpYZkNuQXdMdlJtMEs2Q1Z6WUhPTFVRR2ZVSjBEbGFEeUR3c0JOc009Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
rules:
- operations: ["CREATE"]
apiGroups: [""]
apiVersions: ["v1"]
resources: ["pods"]
admissionReviewVersions: ["v1"]
sideEffects: "None"
failurePolicy: Fail
namespaceSelector:
matchLabels:
polaris-injection: enabled
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
qcloud-app: polaris-controller
name: polaris-controller
namespace: polaris-system
spec:
replicas: 1
revisionHistoryLimit: 10
serviceName: polaris-controller
selector:
matchLabels:
k8s-app: polaris-controller
updateStrategy:
rollingUpdate:
partition: 0
type: RollingUpdate
template:
metadata:
labels:
k8s-app: polaris-controller
app: sidecar-injector
spec:
containers:
- name: polaris-controller
image: polarismesh/polaris-controller:#CONTROLLER_VERSION#
command: ["./polaris-controller"]
args: ["--min-resync-period=60s",
"--leader-elect-namespace=polaris-system",
"--concurrency-polaris-size=100",
"--leader-elect=true"
]
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
imagePullPolicy: Always
volumeMounts:
- mountPath: /polaris-controller/log
name: log
- name: certs
mountPath: /etc/polaris-inject/certs
readOnly: true
- name: inject-config
mountPath: /etc/polaris-inject/inject
readOnly: true
- name: config-volume
mountPath: /etc/polaris-inject/config
readOnly: true
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: qcloudregistrykey
restartPolicy: Always
schedulerName: default-scheduler
terminationGracePeriodSeconds: 30
serviceAccountName: polaris-controller
volumes:
- name: certs
secret:
secretName: polaris-sidecar-injector
- name: inject-config
configMap:
name: polaris-sidecar-injector
items:
- key: mesh-config
path: mesh-config
- key: dns-config
path: dns-config
- key: values
path: values
- name: config-volume
configMap:
name: polaris-controller-config
- hostPath:
path: /data/polaris-controller/log
type: "DirectoryOrCreate"
name: log
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ rules:
resources:
- services
- namespaces
- configmaps
- pods
- endpoints
verbs:
- get
- list
Expand All @@ -25,7 +25,7 @@ rules:
- ""
resources:
- events
- endpoints
- configmaps
verbs:
- create
- update
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 8c40f28

Please sign in to comment.