Skip to content

Commit 13640c7

Browse files
committed
chore(workflow): add check network
1 parent bf85efc commit 13640c7

4 files changed

Lines changed: 66 additions & 47 deletions

File tree

_scripts/install.sh

Lines changed: 65 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,33 @@ function configure_mirrors {
110110
function 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
127140
apiVersion: v1
128141
kind: ConfigMap
129142
metadata:
@@ -132,35 +145,36 @@ metadata:
132145
data:
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
143156
EOF
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

161175
function 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
182205
websecure:
183206
tls:
184207
enabled: true
@@ -190,7 +213,6 @@ additionalArguments:
190213
- "--experimental.http3=true"
191214
- "--entrypoints.name.enablehttp3=true"
192215
EOF
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

234256
function 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
242269
imagebuilder:
243270
container_registries: |
244271
unqualified-search-registries = ["docker.io"]
@@ -252,6 +279,11 @@ imagebuilder:
252279
EOF
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
255287
imagebuilder:
256288
container_registries: |
257289
unqualified-search-registries = ["docker.io"]
@@ -353,6 +385,8 @@ EOF
353385
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
354386

355387
if [[ -z "$@" ]] ; then
388+
check_drycc
389+
check_network
356390
install_k3s_server
357391
install_helm
358392
install_components

charts/workflow/values.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,6 @@ global:
5656
registrySecretPrefix: "private-registry"
5757
# The host port to which registry proxy binds to
5858
registryProxyPort: 5555
59-
# If the Kubernetes cluster uses CNI
60-
# use_cni: true
61-
# Set the `listen` variable for registry-proxy's NGINX
62-
#
63-
# Valid values are:
64-
# - 80: If the Kubernetes cluster run on GKE or AWS, or uses flannel or kubenet as a pod network
65-
# - 127.0.0.1:5555: If the Kubernetes cluster uses CNI
66-
#
67-
# In case of CNI you can not use `hostPort` notation due to https://github.com/kubernetes/kubernetes/issues/23920
68-
# registry_proxy_bind_addr: "80"
6959

7060
# Enable usage of RBAC authorization mode
7161
#

src/managing-workflow/production-deployments.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ Please see the following documentation to learn about disabling Grafana signups:
4848

4949
- [Customizing Monitor][]
5050

51-
## Using on-cluster registry with CNI
52-
53-
If you are using [CNI](https://github.com/containernetworking/cni) for managing container network, you cannot use `hostPort` notation due to [this issue](https://github.com/kubernetes/kubernetes/issues/23920).
54-
In this case you could enable CNI for `drycc-registry-proxy` by setting `use_cni` variable to `true` inside `values.yaml` or by adding `--set global.use_cni=true` to `helm`'s args.
55-
5651
## Running Workflow with RBAC
5752

5853
If your cluster has [RBAC](https://kubernetes.io/docs/admin/authorization/rbac/) amongst your [authorization](https://kubernetes.io/docs/admin/authorization/) modes (`$ kubectl api-versions` should contains `rbac.authorization.k8s.io`) it may be necessary to enable RBAC in Workflow.

src/quickstart/install-workflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ CERT_MANAGER_ENABLED | Whether to use automatic certificat
179179
CHANNEL | By default, `stable` channel will be installed. You can also specify `testing`
180180
REGISTRIES_FILE | The `registers.yaml` file path used by k3s.
181181
BGP_ENABLED | Whether BGP is enabled or not. It is false by default.
182-
BGP_CONFIG_FILE | The bgp config file path used by k3s, after BGP is enabled, the env is required
182+
NETWORK_CONFIG_FILE | The network config file path used by k3s, The default path is `/tmp/network.yaml`
183183
INSTALL_DRYCC_MIRROR | Specify the accelerated mirror location. Currently, only `cn` is supported
184184
CONTROLLER_APP_STORAGE_CLASS | StorageClass allocated by `drycc volumes`; default storageClass is used by default
185185
REDIS_PERSISTENCE_SIZE | The size of the persistence space allocated to `redis`, which is `5Gi` by default

0 commit comments

Comments
 (0)