@@ -129,51 +129,15 @@ function install_k3s_agent {
129129 curl -sfL " ${k3s_install_url} " | INSTALL_K3S_EXEC=" $INSTALL_K3S_EXEC " sh -s -
130130}
131131
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
140- apiVersion: v1
141- kind: ConfigMap
142- metadata:
143- name: bgp-config
144- namespace: kube-system
145- data:
146- config.yaml: |
147- peers:
148- - peer-address: 10.0.0.1
149- peer-asn: 64512
150- my-asn: 64512
151- address-pools:
152- - name: default
153- protocol: bgp
154- addresses:
155- - 192.0.2.0/24
156- EOF
157- else
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
170- fi
132+ function check_metallb {
133+ if [[ " ${METALLB_CONFIG_FILE} " && ! -f " ${METALLB_CONFIG_FILE} " ]] ; then
134+ echo -e " \\ 033[33m---> The path ${METALLB_CONFIG_FILE} does not exist...\\ 033[0m"
171135 exit 1
172136 fi
173137}
174138
175139function install_components {
176- check_network
140+ check_metallb
177141 helm repo update
178142 echo -e " \\ 033[32m---> Waiting for helm to install components...\\ 033[0m"
179143 api_server=(` kubectl config view -o=jsonpath=' {.clusters[0].cluster.server}' | tr " ://" " " ` )
@@ -185,22 +149,40 @@ function install_components {
185149 --set k8sServiceHost=${api_server[1]} \
186150 --set k8sServicePort=${api_server[2]} \
187151 --set hostPort.enabled=true \
188- --set bgp.enabled=${BGP_ENABLED:- false} \
189- --set bgp.announce.loadbalancerIP=true \
190- --set bgp.announce.podCIDR=true \
191152 --namespace kube-system --wait
192-
193- if [[ " ${BGP_ENABLED:- false} " == " true" ]] ; then
194- kubectl apply -n kube-system -f ${NETWORK_CONFIG_FILE}
153+
154+ helm install metallb drycc/metallb --namespace metallb --create-namespace --wait
155+ if [[ -z " ${METALLB_CONFIG_FILE} " ]] ; then
156+ kubectl apply -f - << EOF
157+ apiVersion: v1
158+ kind: ConfigMap
159+ metadata:
160+ name: metallb
161+ namespace: metallb
162+ data:
163+ config: |
164+ address-pools:
165+ - addresses:
166+ - $( ip -o route get to 8.8.8.8 | sed -n ' s/.*src \([0-9.]\+\).*/\1/p' ) /32
167+ name: public
168+ protocol: layer2
169+ - addresses:
170+ - 172.16.0.0/12
171+ name: default
172+ protocol: layer2
173+ EOF
174+ echo -e " \\ 033[32m---> Metallb using the default configuration.\\ 033[0m"
175+ kubectl get cm metallb -n metallb -o yaml
195176 else
196- helm install metallb drycc/metallb --namespace metallb --create-namespace --wait - f ${NETWORK_CONFIG_FILE }
177+ kubectl apply -n metallb -f ${METALLB_CONFIG_FILE }
197178 fi
179+
198180 helm install traefik drycc/traefik \
199181 --namespace traefik \
200182 --create-namespace --wait -f - << EOF
201183service:
202184 annotations:
203- metallb.universe.tf/address-pool: extranet
185+ metallb.universe.tf/address-pool: public
204186 metallb.universe.tf/allow-shared-ip: drycc
205187websecure:
206188 tls:
@@ -233,22 +215,22 @@ function install_openebs {
233215
234216function check_drycc {
235217 if [[ -z " ${PLATFORM_DOMAIN} " ]] ; then
236- echo -e " \\ 033[31m ---> Please set the PLATFORM_DOMAIN variable.\\ 033[0m"
237- echo -e " \\ 033[31m ---> For example:\\ 033[0m"
238- echo -e " \\ 033[31m ---> export PLATFORM_DOMAIN=drycc.cc\\ 033[0m"
239- echo -e " \\ 033[31m ---> And confirm that wildcard domain name resolution has been set.\\ 033[0m"
240- echo -e " \\ 033[31m ---> For example, the current server IP is 8.8.8.8\\ 033[0m"
241- echo -e " \\ 033[31m ---> Please point *.drycc.cc to 8.8.8.8\\ 033[0m"
218+ echo -e " \\ 033[33m ---> Please set the PLATFORM_DOMAIN variable.\\ 033[0m"
219+ echo -e " \\ 033[33m ---> For example:\\ 033[0m"
220+ echo -e " \\ 033[33m ---> export PLATFORM_DOMAIN=drycc.cc\\ 033[0m"
221+ echo -e " \\ 033[33m ---> And confirm that wildcard domain name resolution has been set.\\ 033[0m"
222+ echo -e " \\ 033[33m ---> For example, the current server IP is 8.8.8.8\\ 033[0m"
223+ echo -e " \\ 033[33m ---> Please point *.drycc.cc to 8.8.8.8\\ 033[0m"
242224 exit 1
243225 fi
244226
245227 if [[ -z " ${DRYCC_ADMIN_USERNAME} " || -z " ${DRYCC_ADMIN_PASSWORD} " ]] ; then
246- echo -e " \\ 033[31m ---> Please set the DRYCC_ADMIN_USERNAME and DRYCC_ADMIN_PASSWORD variable.\\ 033[0m"
247- echo -e " \\ 033[31m ---> For example:\\ 033[0m"
248- echo -e " \\ 033[31m ---> export DRYCC_ADMIN_USERNAME=admin\\ 033[0m"
249- echo -e " \\ 033[31m ---> export DRYCC_ADMIN_PASSWORD=admin\\ 033[0m"
250- echo -e " \\ 033[31m ---> This password is used by end users to log in and manage drycc.\\ 033[0m"
251- echo -e " \\ 033[31m ---> Please set a high security string!!!\\ 033[0m"
228+ echo -e " \\ 033[33m ---> Please set the DRYCC_ADMIN_USERNAME and DRYCC_ADMIN_PASSWORD variable.\\ 033[0m"
229+ echo -e " \\ 033[33m ---> For example:\\ 033[0m"
230+ echo -e " \\ 033[33m ---> export DRYCC_ADMIN_USERNAME=admin\\ 033[0m"
231+ echo -e " \\ 033[33m ---> export DRYCC_ADMIN_PASSWORD=admin\\ 033[0m"
232+ echo -e " \\ 033[33m ---> This password is used by end users to log in and manage drycc.\\ 033[0m"
233+ echo -e " \\ 033[33m ---> Please set a high security string!!!\\ 033[0m"
252234 exit 1
253235 fi
254236}
@@ -264,7 +246,7 @@ function install_drycc {
264246builder:
265247 service:
266248 annotations:
267- metallb.universe.tf/address-pool: extranet
249+ metallb.universe.tf/address-pool: public
268250 metallb.universe.tf/allow-shared-ip: drycc
269251imagebuilder:
270252 container_registries: |
282264builder:
283265 service:
284266 annotations:
285- metallb.universe.tf/address-pool: extranet
267+ metallb.universe.tf/address-pool: public
286268 metallb.universe.tf/allow-shared-ip: drycc
287269imagebuilder:
288270 container_registries: |
@@ -386,7 +368,7 @@ export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
386368
387369if [[ -z " $@ " ]] ; then
388370 check_drycc
389- check_network
371+ check_metallb
390372 install_k3s_server
391373 install_helm
392374 install_components
0 commit comments