Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm upgrades #1779

Merged
merged 12 commits into from Mar 24, 2022
Merged

Helm upgrades #1779

merged 12 commits into from Mar 24, 2022

Conversation

SamLR
Copy link
Contributor

@SamLR SamLR commented Mar 22, 2022

Closes: #1778

What changed?

  • Replaced previous chart with one built out from the recommended helm template (i.e. the one created by helm create)
  • Added options to restrict service account impersonation scope. This is important for production usage as without a limited scope on this permission the app can impersonate system:masters which is unacceptable
  • Made the wego-admin user (now renamed wego-test-user) an optional creation
  • Added quality of life fixed like additionalArgs and envVars for greater flexibility

Why?

  • I needed to be able to pass --insecure for deployment (and handle TLS termination in the LB)... things got out of hand

How did you test it?

Running helm template with various settings, e.g.:

$ helm template -n TEST --dry-run --debug \
      --set resources.limits.cpu=320,resources.limits.memory=666 \
      --set resources.requests.cpu=125,resources.requests.memory=333 \
      --set additionalArgs='{a,b,c}' \
      --set envVars\[0\].name=TEST,envVars\[0\].value=foo,envVars\[1\].name=bar \
      --set rbac.impersonationResources='{user,group,serviceaccout}' \
      --set rbac.impersonationResourceNames='{foo,bar}' test ./charts/gitops-server

Documentation Changes

The notes from the README.md should be reflected in the main line website docs (probably in gitops-dashboard) but those look like they need a top-to-bottom overhaul so I wasn't sure where to start.

Note

Ideally the permissions granted to the service account should be further reduced. As I understand it the non-impersonate stanzas exist to support profiles which is not a default use of the UI so should probably be removed but doing so (currently) stops the UI working. I think this should be fixed.

@ozamosi
Copy link
Contributor

ozamosi commented Mar 22, 2022

  • The chart is called weave-gitops in a directory called gitops-server - I think the chart should move to weave-gitops as the old chart is deleted.
  • I believe this needs some changes to tools/helm-values-dev.yaml so that it doesn't break the dev env.

@SamLR
Copy link
Contributor Author

SamLR commented Mar 22, 2022

  • The chart is called weave-gitops in a directory called gitops-server - I think the chart should move to weave-gitops as the old chart is deleted.

I think the question here is should this be "weave-gitops" or "gitops-server" (there're also places we refer to it as "wego-app" still). I don't mind which we go with and, yes, once one is chosen happy to update as many places as I can find.

* I believe this needs some changes to `tools/helm-values-dev.yaml` so that it doesn't break the dev env.

Good catch, will go and check

@SamLR SamLR added the type/enhancement New feature or request label Mar 22, 2022
@josecordaz
Copy link
Contributor

This work looks awesome. Assuming we are using Helm 3... should we also plan on defining a json schema for the file values.yaml ? (values.schema.json). A couple advantages I see are that we can enforce specific value types and required fields when installing, updating or using template subcommand. Or maybe we want to wait a bit more to let weave-gitops to get a bit more mature? 🤔

* Service, this is optional as you may want to limit access to the UI to via
port-forwarding
* Ingress
* Test User -- A test user with hard-coded username & password with minimal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test user is actually a backup admin user in the case that OIDC is failing and cluster ops need to do things.
It is currently undergoing some feature realignment, see the thread here: https://weaveworks.slack.com/archives/C03244W0C8H/p1647967858091769

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you have a backup admin with only read permissions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because those are all i added so far 🙃 , probably because that is all wego core can do right now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from a point of least privilige I'd like to only make it a requirement/recommendation when it's actually in a position to fulfill those extended duties ;)

Comment on lines 47 to 48
username: {{ .Values.testUser.username | b64enc | quote }}
password: {{ .Values.testUser.password | b64enc | quote }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do these need to be b64enc here? i think i remember that k8s will do that automagically when the secret is created

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you do (I just checked against a kind cluster with a simple helm chart). I think the auto-b64encode is only when you use kubectl

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i swear i have seen that as well when just doing like a:

secret := &v1.Secret{
        ObjectMeta: metav1.ObjectMeta{
                Name:      "foo",
                Namespace: "bar",
        },
        Type: "Opaque",
        Data: map[string][]byte{
                "key": []byte("value"),
        },
}

return yaml.Marshal(secret)

even then it is encoded

o well, idk what the rules are 🙃

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bold of you to assume there're rules ;)

replicaCount: 1

image:
# FIXME check the app name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a thing you wanted to fix now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

negotiations are on going https://weaveworks.slack.com/archives/C03244W0C8H/p1647972249151359 :p

Ideally yes but it's not a blocker on this and it may need a wider conversation

Comment on lines 22 to 25
# To enable enterprise OIDC:
# envVars:
# - name: WEAVE_GITOPS_AUTH_ENABLED
# value: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this flag is also needed for the admin user login flow, just in case you wanted to note that.
i think it gates all login functionality, in core as well as ent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to turn this into a variable then, something like:

# Sets the WEAVE_GITOPS_AUTH_ENABLED environment variable to enable login
enable_login: true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeh that sounds good

# in order to work with weave-gitops enterprise
viewSecrets: []

# This should not be used in production
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will (could optionally if they want to) be used in production, we have hijacked the current implementation for easy dev cycles, but it is not meant for that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unclear as to why this would be used in production, is there a ticket for clarifying/resolving it's use there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see that thread I linked. the AdminUser feature is a deliberate one for prod.
I have to write up the tickets now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cf. above thread, is there a reason not to change this when those changes are implemented?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean when #1787 is done? yep makes sense

# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for context, if users make the pod fs read only, i think the profiles mechanism will fail as it writes a disk-based cache

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the profiles mechanism supposed to always be available? I was unclear as to whether it was an enterprise only feature. (this is default copy but once its use is clarified I can update & fix this).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(It has no resolution and I am still confused, but just for context)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually re-reading it does have a resolution, i'll create a ticket to have it behind a flag.
then we can decide what we want to do with it.
i would like it running as a separate service personally.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure what it does but it feels like it's separate to what the rest of the ui is (currently) doing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep 💯 Core v2 has no real concept of what profiles are yet. so let's shuffle it away until they come into scope

Comment on lines 53 to 54
username: not-production-worthy
password: seriously-change-me
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should note that these need to be bcrypted not plain-text

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that in addition to base64 encoded to make them k8s secrets?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(turns out helm has a handy htpasswd function

@SamLR SamLR requested a review from scottrigby March 23, 2022 11:18
@SamLR
Copy link
Contributor Author

SamLR commented Mar 23, 2022

This work looks awesome. Assuming we are using Helm 3... should we also plan on defining a json schema for the file values.yaml ? (values.schema.json). A couple advantages I see are that we can enforce specific value types and required fields when installing, updating or using template subcommand. Or maybe we want to wait a bit more to let weave-gitops to get a bit more mature? 🤔

I think waiting until the interface is a bit more stable would be best. There are a lot of environment variables and parameters that aren't currently exposed which probably should be (I've not because I'm unsure what they all do and how they interact).

@SamLR
Copy link
Contributor Author

SamLR commented Mar 23, 2022

I've created a ticket, #1784, to cover the work in exposing the rest of the various flags & envars that are available to configure the server. @Callisto13 I think this may cover some of the stuff WRT use of the admin user as well?

@Callisto13
Copy link
Contributor

Yep that's fine. We can leave getting the admin user stuff "correct" until we have smoothed out exactly what it is for and what it does.

Sam Cook added 11 commits March 23, 2022 17:23
Helm has a lot of conventions that our existing chart doesn't conform
to. Create a new chart using `helm create gitops-server` that things can
be ported over to
Set e.g. chart name etc based on values in previous version of the chart
As far as I can imagine the gitops-server should never be serving so
much traffic that it needs to autoscale. If it does you probably want to
do something custom anyway.
Make sure we have the correct permissions for the service account by
default
As the gitops-server is effectively an ops tool it may be desirable to
run it with no service resource with access carried out by
port-forwarding or via some other mechanism.
We need a test-user. I'm not sure if this should exist in the main chart
or be included as a sub-chart but their effectively equivalent and, in
theory, as our testing matures this should be something we can remove.
The admin user name & secret location are hard coded into the server
config and there are several questions outstanding for how it will be
used so, rather than add further confusion by trying to change the name,
go back to the original name and make sure that works.
@SamLR
Copy link
Contributor Author

SamLR commented Mar 23, 2022

@Callisto13 I've reverted a load of the 'admin user' bits to closer how they were previously because they're hard coded elsewhere. I've tested it all and I don't think I've broken anything

Copy link
Contributor

@luizbafilho luizbafilho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

and specific resources that the service account can impersonate. e.g.
```yaml
rbac:
create: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not like users have a choice here, they must have impersonation setup otherwise nothing works. So ideally we could have some default values as impersonaionResouces and impersonationResourceNames but allow configuration of those here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've improved how the defaults for impersonationResources is set in ca34285

Much as I'd love to provide defaults for impersonationResourceNames I can't think of a good way to do so. The best solution I've come up with would be to create some default groups (e.g. viewer and editor) that are then the only things to be impersonated. The problem with this is that it requires the user's k8s authentication system to be configured to support them. I suspect this is best solved via documenting common processes for it but that feels very out of the scope of this PR (I'm also not 100% sure this is the best way to do it, I'm not sure who might be the best person to cover this sort of security work).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely, we can't set anything there since there is no way for us to know what groups the companies use. I'm good with that, the important bit that's allowing configuration is there, it should be enough.

Using `toJson` keeps everything on one line which improves legibility
@SamLR SamLR merged commit a176104 into main Mar 24, 2022
@SamLR SamLR deleted the helm-upgrades branch March 24, 2022 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Production version of a helm chart
5 participants