@@ -110,20 +110,33 @@ function configure_mirrors {
110110function install_k3s_server {
111111 configure_os
112112 configure_mirrors
113- INSTALL_K3S_EXEC=" server ${INSTALL_K3S_EXEC} --flannel-backend=none --disable=traefik --disable-kube-proxy --disable=local-storage --cluster-cidr=10.233.0.0/16"
113+ INSTALL_K3S_EXEC=" server ${INSTALL_K3S_EXEC} --flannel-backend=none --disable=traefik --disable=servicelb --disable -kube-proxy --disable=local-storage --cluster-cidr=10.233.0.0/16"
114114 if [[ -n " ${K3S_DATA_DIR} " ]] ; then
115115 INSTALL_K3S_EXEC=" $INSTALL_K3S_EXEC --data-dir=${K3S_DATA_DIR} /rancher/k3s"
116116 fi
117117 if [[ -z " ${K3S_URL} " ]] ; then
118118 INSTALL_K3S_EXEC=" $INSTALL_K3S_EXEC --cluster-init"
119119 fi
120- if [[ " ${BGP_ENABLED:- false} " == " true" ]] ; then
121- if [[ -z " ${BGP_CONFIG_FILE} " ]] ; then
122- echo -e " \\ 033[31m---> Please set the BGP_CONFIG_FILE variable.\\ 033[0m"
123- echo -e " \\ 033[31m---> For example:\\ 033[0m"
124- echo -e " \\ 033[31m---> export BGP_CONFIG_FILE=./bgp.yaml\\ 033[0m"
125- echo -e " \\ 033[31m---> For details, please check bgp.yaml in the current directory\\ 033[0m"
126- cat << EOF > "./bgp.yaml"
120+ curl -sfL " ${k3s_install_url} " | INSTALL_K3S_EXEC=" $INSTALL_K3S_EXEC " sh -s -
121+ }
122+
123+ function install_k3s_agent {
124+ configure_os
125+ configure_mirrors
126+ if [[ -n " ${K3S_DATA_DIR} " ]] ; then
127+ INSTALL_K3S_EXEC=" $INSTALL_K3S_EXEC --data-dir=${K3S_DATA_DIR} /rancher/k3s"
128+ fi
129+ curl -sfL " ${k3s_install_url} " | INSTALL_K3S_EXEC=" $INSTALL_K3S_EXEC " sh -s -
130+ }
131+
132+ function check_network {
133+ if [[ -z " ${NETWORK_CONFIG_FILE} " ]] ; then
134+ echo -e " \\ 033[31m---> Please set the NETWORK_CONFIG_FILE variable.\\ 033[0m"
135+ echo -e " \\ 033[31m---> For example:\\ 033[0m"
136+ echo -e " \\ 033[31m---> export NETWORK_CONFIG_FILE=./network.yaml\\ 033[0m"
137+ echo -e " \\ 033[31m---> Please modify and save the following file contents:\\ 033[0m"
138+ if [[ " ${BGP_ENABLED:- false} " == " true" ]] ; then
139+ cat << EOF
127140apiVersion: v1
128141kind: ConfigMap
129142metadata:
@@ -132,35 +145,36 @@ metadata:
132145data:
133146 config.yaml: |
134147 peers:
135- - peer-address: 10.0.0.1
136- peer-asn: 64512
137- my-asn: 64512
148+ - peer-address: 10.0.0.1
149+ peer-asn: 64512
150+ my-asn: 64512
138151 address-pools:
139- - name: default
140- protocol: bgp
141- addresses:
142- - 192.0.2.0/24
152+ - name: default
153+ protocol: bgp
154+ addresses:
155+ - 192.0.2.0/24
143156EOF
144- exit 1
145157 else
146- INSTALL_K3S_EXEC=" $INSTALL_K3S_EXEC --disable=servicelb"
158+ cat << EOF
159+ configInline:
160+ address-pools:
161+ - name: default
162+ protocol: layer2
163+ addresses:
164+ - 172.16.0.0/12
165+ - name: extranet
166+ protocol: layer2
167+ addresses:
168+ - $( ip -o route get to 8.8.8.8 | sed -n ' s/.*src \([0-9.]\+\).*/\1/p' ) /32
169+ EOF
147170 fi
171+ exit 1
148172 fi
149- curl -sfL " ${k3s_install_url} " | INSTALL_K3S_EXEC=" $INSTALL_K3S_EXEC " sh -s -
150- }
151-
152- function install_k3s_agent {
153- configure_os
154- configure_mirrors
155- if [[ -n " ${K3S_DATA_DIR} " ]] ; then
156- INSTALL_K3S_EXEC=" $INSTALL_K3S_EXEC --data-dir=${K3S_DATA_DIR} /rancher/k3s"
157- fi
158- curl -sfL " ${k3s_install_url} " | INSTALL_K3S_EXEC=" $INSTALL_K3S_EXEC " sh -s -
159173}
160174
161175function install_components {
176+ check_network
162177 helm repo update
163-
164178 echo -e " \\ 033[32m---> Waiting for helm to install components...\\ 033[0m"
165179 api_server=(` kubectl config view -o=jsonpath=' {.clusters[0].cluster.server}' | tr " ://" " " ` )
166180 helm install cilium drycc/cilium \
@@ -176,9 +190,18 @@ function install_components {
176190 --set bgp.announce.podCIDR=true \
177191 --namespace kube-system --wait
178192
193+ if [[ " ${BGP_ENABLED:- false} " == " true" ]] ; then
194+ kubectl apply -n kube-system -f ${NETWORK_CONFIG_FILE}
195+ else
196+ helm install metallb drycc/metallb --namespace metallb --create-namespace --wait -f ${NETWORK_CONFIG_FILE}
197+ fi
179198 helm install traefik drycc/traefik \
180199 --namespace traefik \
181200 --create-namespace --wait -f - << EOF
201+ service:
202+ annotations:
203+ metallb.universe.tf/address-pool: extranet
204+ metallb.universe.tf/allow-shared-ip: drycc
182205websecure:
183206 tls:
184207 enabled: true
@@ -190,7 +213,6 @@ additionalArguments:
190213- "--experimental.http3=true"
191214- "--entrypoints.name.enablehttp3=true"
192215EOF
193-
194216 helm install cert-manager drycc/cert-manager --namespace cert-manager --create-namespace --set installCRDs=true --wait
195217 helm install catalog drycc/catalog \
196218 --set asyncBindingOperationsEnabled=true \
@@ -209,7 +231,7 @@ function install_openebs {
209231 -p ' {"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
210232}
211233
212- function check_drycc_env {
234+ function check_drycc {
213235 if [[ -z " ${PLATFORM_DOMAIN} " ]] ; then
214236 echo -e " \\ 033[31m---> Please set the PLATFORM_DOMAIN variable.\\ 033[0m"
215237 echo -e " \\ 033[31m---> For example:\\ 033[0m"
@@ -232,13 +254,18 @@ function check_drycc_env {
232254}
233255
234256function install_drycc {
235- check_drycc_env
257+ check_drycc
236258 echo -e " \\ 033[32m---> Start installing workflow...\\ 033[0m"
237259 RABBITMQ_USERNAME=$( cat /proc/sys/kernel/random/uuid)
238260 RABBITMQ_PASSWORD=$( cat /proc/sys/kernel/random/uuid)
239261
240262 if [[ " ${INSTALL_DRYCC_MIRROR} " == " cn" ]] ; then
241263 cat << EOF > "/tmp/drycc-values.yaml"
264+ builder:
265+ service:
266+ annotations:
267+ metallb.universe.tf/address-pool: extranet
268+ metallb.universe.tf/allow-shared-ip: drycc
242269imagebuilder:
243270 container_registries: |
244271 unqualified-search-registries = ["docker.io"]
@@ -252,6 +279,11 @@ imagebuilder:
252279EOF
253280 else
254281 cat << EOF > "/tmp/drycc-values.yaml"
282+ builder:
283+ service:
284+ annotations:
285+ metallb.universe.tf/address-pool: extranet
286+ metallb.universe.tf/allow-shared-ip: drycc
255287imagebuilder:
256288 container_registries: |
257289 unqualified-search-registries = ["docker.io"]
353385export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
354386
355387if [[ -z " $@ " ]] ; then
388+ check_drycc
389+ check_network
356390 install_k3s_server
357391 install_helm
358392 install_components
0 commit comments