-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathopsfile.yml
More file actions
190 lines (165 loc) · 5.73 KB
/
opsfile.yml
File metadata and controls
190 lines (165 loc) · 5.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
version: "3"
vars:
DRY: ""
env:
KUBECONFIG:
sh: |
if test -e $OPS_TMP/kubeconfig
then echo $OPS_TMP/kubeconfig
else echo ~/.kube/config
fi
tasks:
listuser:
silent: true
cmds:
- |
if test -n "{{._username_}}"
then
kubectl -n nuvolaris get wsku/{{._username_}} -ojsonpath='{.spec}' | jq .
else
kubectl -n nuvolaris get wsku
fi
deleteuser:
silent: true
cmds:
- |
{{.DRY}} kubectl -n nuvolaris delete wsku/{{._username_}}
{{.DRY}} $OPS -config -r {{._username_}}
adduser:
silent: true
cmds:
- |
export USERNAME={{._username_}}
export EMAIL={{._email_}}
export PASSWORD={{._password_}}
export SECRET_USER_AUTH="$($OPS -random -u):$($OPS -random --str 64)"
# check {{._username_}} is at least 5 chars long
if [ ${#USERNAME} -lt 5 ]
then
$OPS -die "User name must be at least 5 chars long: $USERNAME"
fi
# check {{._username_}} complies with lower case RFC 1123
validate -r '^[a-z0-9](?:[a-z0-9]{0,61}[a-z0-9])?$' $USERNAME "User name must consist of only lower case characters (max 61 chars)"
# check {{._username_}} is not api or api.*
# This cannot happen as the minimum length is 5 chars and the dot would fail the previous check
# so we can disable this check
# validate -r '^api(\..*)?$' $USERNAME "api and any api.* are reserved names."
# check that {{.email}} is a valid email
validate -m $EMAIL "Invalid email: $EMAIL"
# check that password is not empty
if [ -z "$PASSWORD" ]
then die "Password cannot be empty"
fi
# uppercase user to create the secrets in the right format (USERNAME_SECRET_XXX)
upperCaseUser=${USERNAME^^}
$OPS util user-secrets $upperCaseUser
echo "Creating user ${USERNAME}..."
export USER_SECRET_REDIS=$($OPS -config "${upperCaseUser}_SECRET_REDIS")
export USER_SECRET_POSTGRES=$($OPS -config "${upperCaseUser}_SECRET_POSTGRES")
export USER_SECRET_MONGODB=$($OPS -config "${upperCaseUser}_SECRET_MONGODB")
export USER_SECRET_MINIO=$($OPS -config "${upperCaseUser}_SECRET_MINIO")
export USER_SECRET_MILVUS=$($OPS -config "${upperCaseUser}_SECRET_MILVUS")
export REDIS_ENABLED=false
export MONGODB_ENABLED=false
export MINIO_DATA_ENABLED=false
export MINIO_STATIC_ENABLED=false
export POSTGRES_ENABLED=false
export MILVUS_ENABLED=false
export MINIO_STORAGE_QUOTA=auto
if {{.__redis}} || {{.__all}}
then
if $OPERATOR_COMPONENT_REDIS
then
REDIS_ENABLED=true
else
die "Error! Redis is not enabled in OpenServerless"
fi
fi
if {{.__mongodb}} || {{.__all}}
then
if $OPERATOR_COMPONENT_MONGODB
then
MONGODB_ENABLED=true
else
die "Error! MongoDB is not enabled in OpenServerless"
fi
fi
if {{.__minio}} || {{.__all}}
then
if $OPERATOR_COMPONENT_MINIO
then
MINIO_DATA_ENABLED=true
MINIO_STATIC_ENABLED=true
else
die "Error! Minio is not enabled in OpenServerless"
fi
fi
if test -n "{{.__storagequota}}"
then MINIO_STORAGE_QUOTA={{.__storagequota}}
fi
if {{.__postgres}} || {{.__all}}
then
if $OPERATOR_COMPONENT_POSTGRES
then
POSTGRES_ENABLED=true
else
die "Error! Postgres is not enabled in OpenServerless"
fi
fi
if {{.__milvus}} || {{.__all}}
then
if $OPERATOR_COMPONENT_MILVUS
then
MILVUS_ENABLED=true
else
die "Error! Milvus is not enabled in OpenServerless"
fi
fi
envsubst -i user-crd.yaml -o _user-crd.yaml
- |
{{.DRY}} kubectl apply -f _user-crd.yaml
compact:
silent: true
vars:
COUCHDB_HOST: couchdb
COUCHDB_PORT: "5984"
JOB_TTL: "10" # cleanup job after 10 seconds
DB_NAME: "nuvolaris_activations"
cmds:
- |
JOB_TTL={{.__ttl}}
if test -z $JOB_TTL; then
JOB_TTL=10
fi
export COUCHDB_HOST={{.COUCHDB_HOST}}
export COUCHDB_PORT="{{.COUCHDB_PORT}}"
export JOB_TTL=$JOB_TTL
export DB_NAME={{.DB_NAME}}
export COUCHDB_SECRET_NAME=$(kubectl -n nuvolaris get secrets -o name | awk -F'/' '{print $2}' | rg couchdb-auth-)
envsubst -i kubernetes/compact-job.yaml -o kubernetes/_compact-job.yaml
{{.DRY}} kubectl apply -f kubernetes/_compact-job.yaml
usage:
silent: true
cmds:
- |
if {{.__debug}}; then
echo 'flag is {{.__debug}}'
FLAG=--debug
fi
bun usage/usage.js $FLAG