Skip to content

Commit 6396bab

Browse files
committed
feat(workflow): add redis and postgres persistence support
1 parent 721becf commit 6396bab

3 files changed

Lines changed: 69 additions & 84 deletions

File tree

_scripts/install.sh

Lines changed: 41 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,42 @@ 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 --disable=servicelb --cluster-cidr=10.233.0.0/16"
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"
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"
127+
apiVersion: v1
128+
kind: ConfigMap
129+
metadata:
130+
name: bgp-config
131+
namespace: kube-system
132+
data:
133+
config.yaml: |
134+
peers:
135+
- peer-address: 10.0.0.1
136+
peer-asn: 64512
137+
my-asn: 64512
138+
address-pools:
139+
- name: default
140+
protocol: bgp
141+
addresses:
142+
- 192.0.2.0/24
143+
EOF
144+
exit 1
145+
else
146+
INSTALL_K3S_EXEC="$INSTALL_K3S_EXEC --disable=servicelb"
147+
fi
148+
fi
120149
curl -sfL "${k3s_install_url}" |INSTALL_K3S_EXEC="$INSTALL_K3S_EXEC" sh -s -
121150
}
122151

@@ -142,15 +171,11 @@ function install_components {
142171
--set k8sServiceHost=${api_server[1]} \
143172
--set k8sServicePort=${api_server[2]} \
144173
--set hostPort.enabled=true \
174+
--set bgp.enabled=${BGP_ENABLED:-false} \
175+
--set bgp.announce.loadbalancerIP=true \
176+
--set bgp.announce.podCIDR=true \
145177
--namespace kube-system --wait
146-
helm install metallb drycc/metallb --namespace metallb --create-namespace --wait -f - <<EOF
147-
configInline:
148-
address-pools:
149-
- name: default
150-
protocol: layer2
151-
addresses:
152-
- ${METALLB_ADDRESS_POOLS:-172.16.0.0/12}
153-
EOF
178+
154179
helm install traefik drycc/traefik \
155180
--namespace traefik \
156181
--create-namespace --wait -f - <<EOF
@@ -178,6 +203,7 @@ function install_openebs {
178203
helm install openebs drycc/openebs \
179204
--namespace openebs \
180205
--create-namespace \
206+
--set localprovisioner.basePath=${LOCAL_PROVISIONER_PATH:-"/var/openebs/local"} \
181207
--set nfs-provisioner.enabled=true --wait
182208
kubectl patch storageclass ${DEFAULT_STORAGE_CLASS:-"openebs-hostpath"} \
183209
-p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
@@ -240,6 +266,9 @@ EOF
240266
--set global.ingressClass=traefik \
241267
--set fluentd.daemonEnvironment.CONTAINER_TAIL_PARSER_TYPE="/^(?<time>.+) (?<stream>stdout|stderr)( (?<tags>.))? (?<log>.*)$/" \
242268
--set controller.appStorageClass=${CONTROLLER_APP_STORAGE_CLASS:-"openebs-kernel-nfs"} \
269+
--set redis.persistence.enabled=true \
270+
--set redis.persistence.size=${REDIS_PERSISTENCE_SIZE:-5Gi} \
271+
--set redis.persistence.storageClass=${REDIS_PERSISTENCE_STORAGE_CLASS:-""} \
243272
--set minio.persistence.enabled=true \
244273
--set minio.persistence.size=${MINIO_PERSISTENCE_SIZE:-20Gi} \
245274
--set minio.persistence.storageClass=${MINIO_PERSISTENCE_STORAGE_CLASS:-""} \
@@ -258,6 +287,9 @@ EOF
258287
--set passport.adminPassword=${DRYCC_ADMIN_PASSWORD} \
259288
--set database.limitsMemory="256Mi" \
260289
--set database.limitsHugepages2Mi="256Mi" \
290+
--set database.persistence.enabled=true \
291+
--set database.persistence.size=${DATABASE_PERSISTENCE_SIZE:-5Gi} \
292+
--set database.persistence.storageClass=${DATABASE_PERSISTENCE_STORAGE_CLASS:-""} \
261293
--namespace drycc \
262294
--values /tmp/drycc-values.yaml \
263295
--create-namespace --wait --timeout 30m0s
@@ -318,53 +350,6 @@ EOF
318350
echo -e "\\033[32m---> Helmbroker password: $HELMBROKER_PASSWORD\\033[0m"
319351
}
320352

321-
function configure_haproxy {
322-
BUILDER_IP=$(kubectl get svc drycc-builder -n drycc -o="jsonpath={.status.loadBalancer.ingress[0].ip}")
323-
INGRESS_IP=$(kubectl get svc traefik -n traefik -o="jsonpath={.status.loadBalancer.ingress[0].ip}")
324-
325-
if [[ "${USE_HAPROXY:-true}" == "true" ]] ; then
326-
cat << EOF > "/etc/haproxy/haproxy.cfg"
327-
global
328-
log /dev/log local0
329-
log /dev/log local1 notice
330-
chroot /var/lib/haproxy
331-
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
332-
stats timeout 30s
333-
user haproxy
334-
group haproxy
335-
daemon
336-
listen http
337-
bind *:${HAPROXY_HTTP_PORT:-80}
338-
mode tcp
339-
maxconn 100000
340-
timeout connect 60s
341-
timeout client 30000
342-
timeout server 30000
343-
server ingress ${INGRESS_IP}:80 check
344-
listen https
345-
bind *:${HAPROXY_HTTPS_PORT:-443}
346-
mode tcp
347-
maxconn 100000
348-
timeout connect 60s
349-
timeout client 30000
350-
timeout server 30000
351-
server ingress ${INGRESS_IP}:443 check
352-
listen builder
353-
bind *:${HAPROXY_BUILDER_PORT:-2222}
354-
mode tcp
355-
maxconn 100000
356-
timeout connect 60s
357-
timeout client 30000
358-
timeout server 30000
359-
server builder ${BUILDER_IP}:2222 check
360-
EOF
361-
fi
362-
363-
mkdir -p /run/haproxy
364-
systemctl enable haproxy
365-
systemctl restart haproxy
366-
}
367-
368353
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
369354

370355
if [[ -z "$@" ]] ; then
@@ -373,7 +358,6 @@ if [[ -z "$@" ]] ; then
373358
install_components
374359
install_openebs
375360
install_drycc
376-
configure_haproxy
377361
install_helmbroker
378362
echo -e "\\033[32m---> Installation complete, enjoy life...\\033[0m"
379363
else

charts/workflow/values.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,32 @@ database:
204204
# If left empty they will be generated using randAlphaNum
205205
username: ""
206206
password: ""
207+
persistence:
208+
enabled: false # Set to true to enable persistence
209+
accessMode: ReadWriteOnce
210+
size: 5Gi # PVC size
211+
## database data Persistent Volume Storage Class
212+
## If defined, storageClassName: <storageClass>
213+
## If set to "-", storageClassName: "", which disables dynamic provisioning
214+
## If undefined (the default) or set to null, no storageClassName spec is
215+
## set, choosing the default provisioner. (gp2 on AWS, standard on
216+
## GKE, AWS & OpenStack)
217+
##
218+
## Storage class of PV to bind. By default it looks for standard storage class.
219+
## If the PV uses a different storage class, specify that here.
220+
storageClass: ""
221+
volumeName: ""
207222

208223
redis:
209224
# The following parameters are configured only when using an on-cluster Redis instance
210225
replicas: 1
211226
# The following parameters are configured only when using an off-cluster Redis instance
212227
addrs: "" # A list of clusters: "127.0.0.1:7001/1,127.0.0.2:7002/1"
213228
password: "redis password" # "" == no password
229+
persistence:
230+
enabled: false # Set to true to enable persistence
231+
size: 5Gi
232+
storageClass: ""
214233

215234
rabbitmq:
216235
# Configure the following ONLY if using an off-cluster rabbitmq
@@ -222,7 +241,6 @@ rabbitmq:
222241
# GCP PDs and EBS volumes are supported only
223242
persistence:
224243
enabled: false # Set to true to enable persistence
225-
accessMode: ReadWriteOnce
226244
size: 5Gi # PVC size
227245
## rabbitmq data Persistent Volume Storage Class
228246
## If defined, storageClassName: <storageClass>
@@ -234,7 +252,6 @@ rabbitmq:
234252
## Storage class of PV to bind. By default it looks for standard storage class.
235253
## If the PV uses a different storage class, specify that here.
236254
storageClass: ""
237-
volumeName: ""
238255

239256
influxdb:
240257
# URL configuration is only available in off-cluster Influx database

src/quickstart/install-workflow.md

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,6 @@ For RHEL, CentOS, and EKS with EKS Kubernetes Worker AMI with AmazonLinux2 image
6060
$ yum install nfs-utils
6161
```
6262

63-
### Installing haproxy
64-
We use metallb as the loadblance component.
65-
If the host managed by metallb has a public IP, we don't need to install haproxy.
66-
Otherwise, we need to use haproxy to expose ports such as `80` and `443 `.
67-
Ensure that ports `80`, `443` and `2222` cannot be occupied by other applications on the host, and focus on services such as httpd and nginx.
68-
69-
For Debian and Ubuntu, use this command:
70-
71-
```
72-
$ apt-get install haproxy
73-
```
74-
75-
For RHEL, CentOS, and EKS with EKS Kubernetes Worker AMI with AmazonLinux2 image, use this command:
76-
77-
```
78-
$ yum install haproxy
79-
```
80-
8163
### Installing curl
8264

8365
For Debian and Ubuntu, use this command:
@@ -189,17 +171,19 @@ $ curl -sfL https://drycc.cc/install.sh | bash -s - install_k3s_agent
189171
When using this method to install drycc, the following environment variables can be used to configure the installation:
190172

191173
ENVIRONMENT VARIABLE | DESCRIPTION
192-
-------------------------------------------|---------------------------------------------------------------------------------------------------------
174+
-------------------------------------------|---------------------------------------------------------------------------------------------
193175
PLATFORM_DOMAIN | Required item, specify drycc's domain name
194176
DRYCC_ADMIN_USERNAME | Required item, specify drycc's admin username
195177
DRYCC_ADMIN_PASSWORD | Required item, specify drycc's admin password
196178
CERT_MANAGER_ENABLED | Whether to use automatic certificate. It is `true` by default
197179
CHANNEL | By default, `stable` channel will be installed. You can also specify `testing`
198180
REGISTRIES_FILE | The `registers.yaml` file path used by k3s.
199-
USE_HAPROXY | Haproxy is enabled by default. If you want to turn it off, this value is false
200-
METALLB_ADDRESS_POOLS | IP pool for LoadBalancer. The default is `172.16.0.0/12`
181+
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
201183
INSTALL_DRYCC_MIRROR | Specify the accelerated mirror location. Currently, only `cn` is supported
202184
CONTROLLER_APP_STORAGE_CLASS | StorageClass allocated by `drycc volumes`; default storageClass is used by default
185+
REDIS_PERSISTENCE_SIZE | The size of the persistence space allocated to `redis`, which is `5Gi` by default
186+
REDIS_PERSISTENCE_STORAGE_CLASS | StorangeClass of `redis`; default storangeclass is used by default
203187
MINIO_PERSISTENCE_SIZE | The size of the persistence space allocated to `minio`, which is `20Gi` by default
204188
MINIO_PERSISTENCE_STORAGE_CLASS | StorangeClass of `minio`; default storangeclass is used by default
205189
MONITOR_GRAFANA_PERSISTENCE_SIZE | The size of the persistence space allocated to `monitor.grafana`, which is `5Gi` by default
@@ -208,13 +192,13 @@ INFLUXDB_PERSISTENCE_SIZE | The size of the persistence space a
208192
INFLUXDB_PERSISTENCE_STORAGE_CLASS | StorangeClass of `influxdb`; default storangeclass is used by default
209193
RABBITMQ_PERSISTENCE_SIZE | The size of the persistence space allocated to `rabbitmq`, which is `5Gi` by default
210194
RABBITMQ_PERSISTENCE_STORAGE_CLASS | StorangeClass of `rabbitmq`; default storangeclass is used by default
195+
DATABASE_PERSISTENCE_SIZE | The size of the persistence space allocated to `database`, which is `5Gi` by default
196+
DATABASE_PERSISTENCE_STORAGE_CLASS | StorangeClass of `database`; default storangeclass is used by default
211197
HELMBROKER_PERSISTENCE_SIZE | The size of the persistence space allocated to `helmbroker`, which is `5Gi` by default
212198
HELMBROKER_PERSISTENCE_STORAGE_CLASS | StorangeClass of `helmbroker`; default storangeclass is used by default
213199
K3S_DATA_DIR | The config of k3s data dir; If not set, the default path is used
214-
LONGHORN_DATA_PATH | The defaultDataPath of longhorn; If not set, the default path is used
215-
HAPROXY_HTTP_PORT | The drycc ingress http port of haproxy for external exposure, default `80`
216-
HAPROXY_HTTPS_PORT | The drycc ingress https port of haproxy for external exposure, default `443`
217-
HAPROXY_BUILDER_PORT | The drycc builder port of haproxy for external exposure, default `2222`
200+
DEFAULT_STORAGE_CLASS | K3s default stroageclass, If not set, the `openebs-hostpath` stroageclass is used
201+
LOCAL_PROVISIONER_PATH | Local path storage path, If not set, the `/var/openebs/local` path is used
218202

219203
Since the installation script will install k3s, other environment variables can refer to k3s installation [environment variables](https://rancher.com/docs/k3s/latest/en/installation/install-options/).
220204

0 commit comments

Comments
 (0)