Skip to content

Commit 28dadbc

Browse files
Merge pull request #213 from stfc/updates-to-galaxy
MAINT: make galaxy use secrets
2 parents 66fcb93 + 0609709 commit 28dadbc

File tree

8 files changed

+147
-69
lines changed

8 files changed

+147
-69
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
oauth2-proxy:
2+
3+
# IRIS IAM CLIENT CREDENTIALS
4+
config:
5+
clientID: iris-iam-client-id
6+
clientSecret: iris-iam-secret
7+
# Create a new secret with the following command
8+
# openssl rand -base64 32 | head -c 32 | base64
9+
cookieSecret: "XXXXXXXXXXXXXXXX"
10+
11+
# if you want to setup galaxy where only specific emails have access
12+
# USE EITHER THIS OR RESTRICT BY OIDC GROUP
13+
authenticatedEmailsFile:
14+
# if you're using oidc - set this to false
15+
enabled: true
16+
restricted_access: |-
17+
18+
19+
20+
# if you want to setup galaxy where only a specific IAM group has access
21+
# USE EITHER THIS OR RESTRICT BY EMAILS ABOVE
22+
# extraArgs:
23+
# allowed-group: "stfc-cloud/admins"
24+
25+
galaxy:
26+
postgresql:
27+
# a random consistent password for postgres galaxydbuser
28+
# can't auto-generate a password because of argo-helm issues when it tries to reconcile
29+
galaxyDatabasePassword: <random-password>
30+
configs:
31+
galaxy.yml:
32+
galaxy:
33+
# comma spaced list of admin emails
34+
35+
36+

charts/dev/materials-galaxy/values.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
galaxy:
2-
32
# RBAC is defined by admins once service is up
43
rbac:
54
enabled: true
@@ -98,8 +97,6 @@ galaxy:
9897
remote_user_secret: null
9998

10099
# admin user config
101-
# comma spaced list of admin emails - need to change this to have admins
102-
admin_users: "[email protected]"
103100
allow_user_deletion: true
104101
allow_user_impersonation: true
105102

@@ -350,11 +347,6 @@ galaxy:
350347

351348
oauth2-proxy:
352349
# Oauth client configuration specifics
353-
config:
354-
355-
#TODO: make this a secret
356-
existingSecret: iris-iam-credentials
357-
358350
extraArgs:
359351
upstream: "http://{{.Release.Name}}-nginx"
360352
redirect-url: "https://galaxy.example.com/oauth2/callback"

clusters/dev/galaxy/apps.yaml

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ metadata:
2929
namespace: argocd
3030
spec:
3131
goTemplate: true
32+
goTemplateOptions: ["missingkey=invalid"]
3233
generators:
3334
- list:
3435
elements:
@@ -51,11 +52,6 @@ spec:
5152
chartName: longhorn
5253
namespace: longhorn-system
5354
valuesFile: ../../../clusters/dev/galaxy/argocd-setup-values.yaml
54-
55-
- name: manila-csi
56-
chartName: manila-csi
57-
namespace: manila-csi
58-
valuesFile: ../../../clusters/dev/galaxy/argocd-setup-values.yaml
5955

6056
# disable galaxy - deploying manually to diagnose duplicate job bug
6157
# - name: materials-galaxy
@@ -81,6 +77,8 @@ spec:
8177
helm:
8278
valueFiles:
8379
- "{{.valuesFile}}"
80+
# a hack to get optional secrets working
81+
- secrets://{{ .secretsFile | default "../../../secrets/dummy-secret.yaml"}}
8482
destination:
8583
server: https://kubernetes.default.svc
8684
namespace: "{{.namespace}}"
@@ -92,19 +90,3 @@ spec:
9290
allowEmpty: true
9391
syncOptions:
9492
- CreateNamespace=true
95-
96-
templatePatch: |
97-
{{- if eq .name "manila-csi" }}
98-
spec:
99-
ignoreDifferences:
100-
- group: rbac.authorization.k8s.io
101-
kind: ClusterRole
102-
name: manila-csi-openstack-manila-csi-controllerplugin
103-
jsonPointers:
104-
- /rules
105-
- group: rbac.authorization.k8s.io
106-
kind: ClusterRole
107-
name: manila-csi-openstack-manila-csi-nodeplugin
108-
jsonPointers:
109-
- /rules
110-
{{- end }}

clusters/dev/galaxy/materials-galaxy-values.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
oauth2-proxy:
2+
3+
24
extraArgs:
3-
# limit access to stfc-cloud-dev group
4-
allowed-group: "stfc-cloud-dev"
55
redirect-url: "https://galaxy.dev.nubes.stfc.ac.uk/oauth2/callback"
66

77
galaxy:
8-
configs:
9-
galaxy.yml:
10-
galaxy:
11-
# comma spaced list of admin emails
12-
admin_users: "[email protected]"
13-
148
ingress:
159
hosts:
1610
- host: "galaxy.dev.nubes.stfc.ac.uk"

docs/apps/galaxy.md

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,10 @@ This is because:
8888

8989
3. Its seamless! Users will be redirected to IRIS IAM login page before accessing Galaxy.
9090

91-
To set an allowed IAM Group you can add the following
92-
```yaml
93-
oauth2-proxy:
94-
extraArgs:
95-
allowed-group: "my-group" # or name of your IRIS IAM group
96-
```
97-
9891
Other oauth2 proxy config settings can be found here - https://oauth2-proxy.github.io/oauth2-proxy/configuration/overview/. Flags can be passed as `extraArgs`
9992

93+
NOTE: see creating Sops secret about configuring oidc authorization to Galaxy
94+
10095

10196
### Configuring DNS + certs
10297

@@ -128,41 +123,37 @@ galaxy:
128123

129124
## Pre-deployment steps
130125

131-
### 1. Create Secret for IAM Credentials
126+
### 1a. Create Sops Secret (If using ArgoCD)
132127

133-
Create a secret for IAM credentials you can do so by creating a file in `/tmp/iam-secret.yaml` and adding this config:
128+
Galaxy requires `iris-iam` client id and secret to be setup.
134129

135-
```yaml
136-
apiVersion: v1
137-
data:
138-
client-id: "" # put client id here - remember to encode it in base64
139-
client-secret: "" # put client secret here - remember to encode it in base64
140-
cookie-secret: "" # any 32 digit alphanumeric
141-
kind: Secret
142-
metadata:
143-
name: iris-iam-credentials
144-
namespace: galaxy # make sure this matches namespace galaxy will be installed in
145-
type: Opaque
146-
```
147-
148-
you can create a random cookie secret by running
149-
```bash
150-
openssl rand -base64 32 | head -c 32 | base64
151-
```
130+
Additionally, if you want to restrict access to galaxy using emails - these should be setup using a sops secret
131+
132+
You can set these secrets using `sops` - template yaml files for setting these secrets can be found in `secret-templates`. See [secrets](../secrets.md) on how to set and encrypt these secrets using sops
133+
134+
### 2. Set Secrets in sops (If not using ArgoCD)
135+
136+
You'll need to configure IRIS-IAM credentials manually using the template yaml files. Copy these files to tmp directory to avoid committing secrets
152137

153-
Then just apply the file
154138
```bash
155-
kubectl apply -f /tmp/iam-secret.yaml
139+
cp charts/$env/$chartName/secret-templates/* /tmp/secret-templates
156140
```
157141

142+
### 3. Set Postgresql Galaxy User Password
143+
144+
We need to set a consistent password for galaxy user to access the prosgresql database (under `galaxy.postgresql.galaxyDatabasePassword`)
145+
Alternatively you can use an existing secret in K8s using (`galaxy.postgresql.galaxyExistingSecret` and `galaxy.postgresql.galaxyExistingSecretKeyRef`)
146+
147+
This is mandatory if you're using ArgoCD - see Common Problems No. 2
148+
158149
## Deployment
159150

160151
You can deploy the chart as standalone
161152

162153
```bash
163154
cd cloud-deployed-apps/charts/dev/materials-galaxy
164155
helm dependency upgrade .
165-
helm install my-galaxy-service . -n galaxy --create-namespace
156+
helm install my-materials-galaxy . -n materials-galaxy --create-namespace -f /tmp/secret-templates/materials-galaxy.yaml
166157
```
167158

168159
or you can use argocd to install it - see [Deploying Apps](../deploying-apps.md)
@@ -173,3 +164,9 @@ or you can use argocd to install it - see [Deploying Apps](../deploying-apps.md)
173164
### 1. Galaxy pods stuck initializing and db init job crashlooping
174165

175166
**Solution**: If you're using our longhorn chart, you will need to change `longhorn.persistence.migrateable` to `false` since RWX volumes are incompatible with this. Delete the pvc/pv and restart the job and it should work
167+
168+
### 2. Galaxy spins up but reconciliation leads to various pods end up stuck in pending
169+
170+
**Solution**: If you're using ArgoCD and not setting a consistent password for `postgresql.galaxyDatabasePassword` (or `postgresql.galaxyExistingSecret`) it will end up autogenerating a new password every time ArgoCD reconciles the Galaxy chart.
171+
172+
This will cause the init-db job to fail as it expects the old password to work. This issue can be mitigated by setting a consistent password. This relates to a helm issue around autogenerated secrets https://github.com/galaxyproject/galaxy-helm/issues/112

scripts/deploy.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ if [ -z "$2" ]; then
1414
exit 1
1515
fi
1616

17-
1817
CLUSTER_NAME=$1
1918
ENVIRONMENT=$2
2019

@@ -33,8 +32,7 @@ if ! kubectl get secret helm-secrets-private-keys -n argocd &> /dev/null; then
3332
fi
3433

3534
# Installing cert-manager if it's not already installed (relevant for child clusters)
36-
kubectl get namespace cert-manager &> /dev/null || true
37-
if [[ $? -eq 0 ]]; then
35+
if kubectl get namespace cert-manager &> /dev/null; then
3836
echo "cert-manager already installed..."
3937
else
4038
echo "installing cert-manager"
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
oauth2-proxy:
2+
#ENC[AES256_GCM,data:mrdeIB3Nv/x4WLnuRtf/RimCebZCVUrawJHE7A==,iv:8bKF55aVjMHhwlW6Zrfc+vACeucfCCHnG3zJpBFc+yM=,tag:hHpGPxOCao3WwtPz5ah/Kg==,type:comment]
3+
config:
4+
clientID: ENC[AES256_GCM,data:fA2ePSbC0kd+GMXnamcGCjauMF4ICrrf1xHeKIQO6TMcP5Kk,iv:G3E626rJUNaunLCbqj9b1ieDhr63mxD6zxJBB/gu0yQ=,tag:xqwO+cHFZ81jLNZF1NuoCA==,type:str]
5+
clientSecret: ENC[AES256_GCM,data:Z5yjU0gLBaqYGcPcKjjvJlbQY8jmseijt0Q0MZNXgZnNjAtW8GQJStZvIeJOlY2G14aWkYktCZyGfxVOzrMvjzRjI6uKjSKA9u8xMxD6xlr1uoLjFGE=,iv:IykhmrEfrbQxSw7v9b6jmOexdRkOFOrKK+4tGQ3cU0M=,tag:veeVZmwJ6B3LpicC36yumQ==,type:str]
6+
#ENC[AES256_GCM,data:uassv+ORXcu726uwSNPzll+9ilpz6x19bkH5X4PgbdJc/uqLUm+gHbG8FJ0HQ6k=,iv:wTWpghowGnalACjsO6RWo6HagO8K+GYaNX5s2bkribk=,tag:AE7PfEzpUDxYy5mreEVWCw==,type:comment]
7+
#ENC[AES256_GCM,data:bktxsU/8UwmxKaETZE/Q4r9xjLca1PC5pM4zXWo2TTQEjgB/W6zHu8fZolFx5w==,iv:hL+j99HxA9QOdUKj/nvgCsdFYQOJ4KzYx53gk5+JDUw=,tag:AimCeTrA8ouFLjh46VuRUw==,type:comment]
8+
cookieSecret: ENC[AES256_GCM,data:l+pVAlzzHt1HkHBXOYQMMBRvEPPpgL0OlNAl1KLP+0onZTxpm/pEassWzgI=,iv:PzULUSFQvFPlvGyC3W2T0L6fcOYDom0cc1JXCbG7dSQ=,tag:tEH3dCg9CkJys891BQvVhg==,type:str]
9+
authenticatedEmailsFile:
10+
enabled: ENC[AES256_GCM,data:ZrYngw==,iv:jlvezGvNk9xYvLOvUOlTEIsCYGoovmm4TK8kGYDuW/k=,tag:Q2fTk9dmABVRwhznwFoIow==,type:bool]
11+
restricted_access: ENC[AES256_GCM,data:naI9w7dNvnb88zOEdeQi4bmG8I6xmr2VRuzGBYU+/uze993/M6Fk9kqvkAC7cRgdhkuGzamnwsGauARcciY/AFZz/+aZzXwnpqfRFy3rtlx0bApc+pjtOqtBL/HAnzef/dq8j3eqbKPjTE4zsb/mAQvlH8VyAU2aF3/dR75YeUDcSRah8ersexk2g2r2KR0t7xJ4sQDWmZxi9EGsK99V5yrsrgw3FTAE1GLYUpw5UudCkC6dneJb3iyDqLi0LHT+dTwIBV3dQSgFV8mPV66mUrQT5sxJVlHSCyNvfclK/9miLgsiB/Kz1Z9W/iys6KLrCugtmsadATLH6ZsxVdDAz89tF0udrfVzmWstxxYGE8sy5yU6UAJnAxYhf/0CohToy/XjoJ0jqUXJAc3oQf1fB7MwtfXsp1xw/77RBYr6kZFS6awUIh7KnVi+UX2hDvQzWcrlZ2otJe1a/3kGi4UL9Py7sq7eZKmqYFqKycI+pYHn63W2V77OmtX41js5QVwUd6eCTKRpLb8LNtogQvhdUQnL6/b8syRRCfNvsubbisilZxgLS3rEcdqW7DzNOFk=,iv:mbl58rnmrwrz39bdhI/inoGGCaBcCAHj0dAELQ57JEo=,tag:JHTmTGBcNosqAjFl+Nygkg==,type:str]
12+
galaxy:
13+
postgresql:
14+
#ENC[AES256_GCM,data:MCh8ZsHTNCUMfGKsnHNv/y059jOchh3hD6pBvDDNOmQUvLCvaNzPMMqRYaxS+RtdJ8GL8R7Yfg==,iv:LxTMl3r6RGCkSinEjHef+2G6TDxiusZxmdOKZFuoHSM=,tag:urFSeeIH1qo6UI1bBblbiw==,type:comment]
15+
#ENC[AES256_GCM,data:VYrPLdtahkqRMbw4uccj/xk695BIhSsSPGIZe1NWbNZ18ymTs7EwVcwvNy8xOgI9hCMSMiCXSA==,iv:h67d9d6C+ZTl+XxzMbPgtCMDCnuVfGNvZOXumh0ZAv4=,tag:UixwGTLQeuuG1MqVdl6Atw==,type:comment]
16+
galaxyDatabasePassword: ENC[AES256_GCM,data:x7N59RQ5d51TQF3NOK1XqA==,iv:bUUD968sLAZeRn/v0wI5JqceFwtA04LpUrzBs3XkjOQ=,tag:mKzbT7IGxyHdpZTsaY/0xw==,type:str]
17+
configs:
18+
galaxy.yml:
19+
galaxy:
20+
#ENC[AES256_GCM,data:RmB2DIN1leHqA6+yDCL3r067j7zAzDceM05DhmLYGAZL3Q==,iv:KfBO4dzEKTybK2BLRkIqHdkFIfrYAlRzWXDTYrgEEP4=,tag:fu/Zv3L+f18sZIlX8RWWhg==,type:comment]
21+
admin_users: ENC[AES256_GCM,data:SweYaLL+q/XaZYiQ4Aasa2B7+aGcloZAKjrxZheMLphf9uYWcz3/X2BfDuSJmiQbCl8hDBSVnipM0hssMHXGryiI5251qS7M/bPX0smOBd27DafIhobun5yb3cmg/13ppEKCcqo8vmB9RLupOTdo,iv:uDDS6pvnQ4bE4iqPxM8C+FJzxYzC5GrNaWdeL3fu9+U=,tag:q/IuLW7I8AwrM24BNQjCXg==,type:str]
22+
sops:
23+
kms: []
24+
gcp_kms: []
25+
azure_kv: []
26+
hc_vault: []
27+
age:
28+
- recipient: age1acqcungzwkt807d3jt94ngtdt0vhk9kec4ps4a22cpaah57jw4xsl7q4xc
29+
enc: |
30+
-----BEGIN AGE ENCRYPTED FILE-----
31+
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBZdmpOYkltUHRnSUNoSi9W
32+
UzRwN3NkS01pSmhEUGVUZzFCeERzTVZDY2hnCk5UbVZIUWo2VXpTTVNEaVdtaTIx
33+
OHhCSXZsbjFxdzZWMnhoUTJPMlVDOTgKLS0tIDB3bHAvWDQvVVRMMExEODY2T3Fz
34+
M2RJNE0rakFDR2hLNDYvN2wyZ1V4NjAKoYldmwafjnM+ZYjwtUEv3vGMzejfCk7W
35+
Y95yjXtZxYad5XqPwVazYBGQCjTNyhbEgsSheQAHYZLLu3tL17clcg==
36+
-----END AGE ENCRYPTED FILE-----
37+
- recipient: age1h3dmygqf4v6jg3nxk5sr9jkp27w3q83sqnqxdd5n92xf3w6fs5kshakrxn
38+
enc: |
39+
-----BEGIN AGE ENCRYPTED FILE-----
40+
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBrVnBxZEs3WDMvNWpRa2Vy
41+
cDNZWTRwbk5hdjh4QVJVQy9BZDRPTW1xS3hFCldVc1U1aEhMdHFPQXRwb0hjcElN
42+
eWp6ZWtLNWtXRXRMbDRra3NsSVpVa2sKLS0tIGVCcmptZFN1bktoM0VpUmc3YkRN
43+
ckg5My9tcFY4MUtMT2JTWkdqejEzSncKMCsx4V+4OJ61il6Q6CTQItuqzFoIOIgy
44+
LkoT7afaqKfnTTvKHhDEHEdAEMDOkeOPL/BLlhXxmyeD1jEBxwhy4A==
45+
-----END AGE ENCRYPTED FILE-----
46+
- recipient: age1xr298hh8ammzethfcdeh72c25wnrk3u2zlzxx78k4nfcq2rwpgqs9hljq8
47+
enc: |
48+
-----BEGIN AGE ENCRYPTED FILE-----
49+
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBvSVhkUHBSODRjekpnT0FI
50+
WlBSQlpacEU4d2htSll1bCtPYUhSWENzaW5rCmxmb0w3cEJoR0NDQXBpN29SbGND
51+
Q3pMTkxnelVaVVA2R25iR0tlbXMwUW8KLS0tIFM2TTJydEJ5SmRzbW1XTEtDZnh3
52+
cUIvN0dFWW9jMHBjdjJGSHd3aEZTeG8K9JtaswOcZljGLxIXKXVgG33TMRgViT6M
53+
UOP6kZT3mgSLuERiP6qt+i/EYP/lHNsLrf/t5+EwXaYYITR/CeC3mw==
54+
-----END AGE ENCRYPTED FILE-----
55+
- recipient: age12khufkd7z25eqgpjjyy0zcrq6kpjxzekmff5zhq7q54tajm4e58qul35x0
56+
enc: |
57+
-----BEGIN AGE ENCRYPTED FILE-----
58+
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBNeGJjQXRZMVNxczdsQzM1
59+
ZGU4ajN1MTE2dlhLcXN3bExpTVZIbHFlMlFnCjJNMEJtUXVJVjBMaXFkbDJVd1U1
60+
ODNDK1JGR2wzWEk4SmowN1QvZlorQ0kKLS0tIDFraWpsay92SXhJcEFGSE5pNjFD
61+
T3JtOGQyaDI0bllGSTFQVzRLWjVJR2sKSXluwjAnx9Bm19C9S6OVE/qpnACa4zy9
62+
w5LKfHWeI3SU+ELrkppgRwo1OHCMZ06uZLYfUz6yDGvK93eVoxC/Pw==
63+
-----END AGE ENCRYPTED FILE-----
64+
- recipient: age16fufeddr0arrns268526gxethxgkh3g0euf8cn37kuwfmq3h23psutz4q8
65+
enc: |
66+
-----BEGIN AGE ENCRYPTED FILE-----
67+
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB3M3JKSjlMK3lsQ3Noa24z
68+
OTJkSWxHZ3hwUE5UQUJkYjViTFJNRmc4T2xnCmUxMEtFVEh4aTZoV3JUcEZoeFJr
69+
bFpjcDA4UXRsekFuai9Db0JocjllVE0KLS0tIEpUZmJxbWQrRW1nQmx6eE1rbzBL
70+
M3NjYVBUMkJwNXpRMms5dnRQU3FTeFEK3Xv8FnUAT2tzCwcq39/tRnLVCXyznrpq
71+
ZvVqOqreF0cSflft3QSwfXHYLp8n/H8rX80eUUEtTf+veIgP99cZqQ==
72+
-----END AGE ENCRYPTED FILE-----
73+
lastmodified: "2024-10-15T20:58:09Z"
74+
mac: ENC[AES256_GCM,data:IwZVidMlOOCr3kcu5pgdm0I97Con30RrSZ6LuSbPLH4IPwttJEj6RiTC5kSos5+vAcy/mrlDtIcGrr3/t5CVs9f9+9PHasVOnEBts+moO3XISK1Ep+YbwOiF5lcHzq+rU2e2gJlnQ+QHjMB2yAzYI+DQBeEKc7+mG7cDcHgj+oA=,iv:HOL+/z3p8bXZtMYrjN9V9y/VazJd/PDovyYDQ+yfl5o=,tag:p1ulTRltYD1e4mih9gitnw==,type:str]
75+
pgp: []
76+
unencrypted_regex: ^(apiVersion|metadata|kind|type)$
77+
version: 3.8.1

secrets/dummy-secret.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This file is left purposefully empty to act as a "dummy" secrets file to
2+
# get argocd appsets to function properly

0 commit comments

Comments
 (0)