-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Epic: Allow for custom annotations & env variables on K8s Resources for Self-Hosted Installations #10461
Comments
I doubt that we want to support post-processing in the near future. Instead, we should open issues for the missing configuration options customers are doing currently with post-processing and solve this properly. See also this internal comment. |
Here is the current list of known example customisations that are being done by customers via post-processing,. which can partly now be done via experimental config OR which would benefit from having customisable annotations:
|
I'm going to propose this as the new config structure: experimental:
annotations:
common:
key: value
kind:
<k8s_kind>:
<component_name>:
key1: value1 This would allow a common annotation on ALL components, but also fine-grained control of components based upon the kind (eg, I'm going to propose only applying this to Are we happy with this as a config definition and implementation? @lucasvaltl @corneliusludmann |
I think we should NOT put this under Regarding the config object structure. Just a random idea. I would like a structure like this but it could be more difficult to parse. What do you think?
Otherwise, I'm fine with your more simpler version of the structure. Maybe we can make |
Proposed DocumentationThere are times when it is desirable for custom annotations, envvars and labels should be added to an installation. Installer ConfigThis can be added to the root of the The structure is based upon the standard Kubernetes resource definition. For annotations and labels, these must match the customization:
- apiVersion: "*"
kind: "*"
metadata:
name: "*"
annotations:
appliedToAll: value
hello: world
labels:
appliedToAll: value
hello: world
- apiVersion: "apps/v1"
kind: "Deployment"
metadata:
name: "ws-manager"
annotations:
hello: ws-manager
labels:
hello: ws-manager
spec:
env:
- name: HELLO
value: world This example would generate the following spec (these are simplified for readability reasons): ---
# apps/v1/DaemonSet ws-daemon
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
app: gitpod # system-value
component: ws-daemon # system-value
appliedToAll: value
hello: world
annotations:
appliedToAll: value
hello: world
name: ws-daemon
---
# apps/v1/Deployment ws-manager
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: gitpod
component: ws-manager
appliedToAll: value
hello: ws-manager
annotations:
appliedToAll: value
hello: ws-manager
name: ws-manager
spec:
template:
spec:
containers:
- env:
- name: HELLO
value: world In the event of multiple matches, the final matching customization would be applied. For that reason, it is a good idea to structure your customization from least to most specific. System-generated values will never be overridden. Validation
KOTS ConfigThis is a raw YAML object that will be applied to the Installer config as-is - it will be a file upload (similar to the patch) as it's easier to create YAML files in an IDE than it is in a plain We will attempt validation with a preflight check. It's not currently clear how this will work, but should be possible |
Thanks for writing this up @mrsimonemms ! Helps me understand how this would work in context I hope you found it helpful as well! This raises a couple questions (happy to jump on a call):
|
@lucasvaltl I'll answer in order, but a call with you is always nice
|
This also supporting labels would complete it as a feature for use by CS, different customers have different org requirements for how their workloads are deployed - some use labels to track things like hosting cost chargeback to the department that provisioned the app for example. The difference between Labels and Annotations is that Labels would need to be applied to all resources, not just a subset (but should also be harmless if we prevent users from changing the app and component keys, that gitpod uses itself). Re: preflight, assuming the gitpod-installer is doing the evaluation of these customizations to apply them, wouldn't adding a But +1 from me for going in this direction |
@mrzarquon that's one option. There is already a validation command in the Installer ( tl;dr - I'll figure something out |
What do you think about a file upload instead? Reasoning:
Drawback:
|
Good call @corneliusludmann. I'll change the docs comment to reflect that |
Edit to docs
|
Suggest to only support: All components except:
Resources to include - others are likely to have unintended consequences:
|
The format seems a bit cryptic. How about something that's closer to Kubernetes? customization:
- kind: Pod
metadata:
annotations:
appliesToAllPods: "notice the omitted name"
- kind: Pod
metadata:
annotations:
appliesToAllPods: "will override the previous value"
- kind: Service
name: proxy
metadata:
labels:
stage: production
companyPolicy: foobar
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: external
- kind: Pod
name: ws-manager
metadata:
labels:
foo: bar
spec:
env:
- name: DEMO_GREETING
value: "Hello from the environment"
- name: DEMO_FAREWELL
value: "Such a sweet sorrow" All applicable customisations are applied in order. Using the example above, for the apiVersion: v1
kind: Pod
metadata:
labels:
foo: bar
annotations:
# whatever came from the installer
appliesToAllPods: "will override the previous value"
spec:
containers:
- name: ws-manager
env:
# whatever came from the installer
- name: DEMO_GREETING
value: "Hello from the environment"
- name: DEMO_FAREWELL
value: "Such a sweet sorrow" By default the |
Thanks @csweichel. I like the approach and think there's a lot of merit in this, especially as it's idiomatic in the k8s space. Two potential drawbacks I can see are:
I suspect that, because this is a feature request from customers, this may require several iterations before we get it to cater for everyone's needs. My suggestion would be that we go with the simple one in the WDYT @corneliusludmann? |
Great point. Instead of omitting any of those fields, we could use
If that happens there likely is a need for it - and then we can discuss what they're trying to solve and if this is the right way. That said, I'm more worried about the small differences, e.g. the omission of the container name. Don't have a solution here, and agree that we're unlikely to get it right the first time.
Frankly this sounds to me a bit like we're just going to push this problem out into the future. I'd hope that a v2 config is still reasonably far away, considering the breaking experience that would produce all around. |
In PR #10857 the question has arisen from @aledbf whether we want to protect existing annotations/env vars/labels. As long as our existing customer use cases do not speak against it, I'm happy with protecting all existing ones in the |
Edit: Updated the docs to reflect the spec that @csweichel proposed. Also made reference that system properties cannot be overridden. |
Marking this as complete - @mrsimonemms is the outstanding issue (#10908) still relevant? |
@lucasvaltl no, that's sort of a duplicate of the "check config" preflight - will close |
Summary
Allow users to customise to adapt their deployment of self-hosted to the specifics of the environment/cluster it is applied to.
Context
Customers are finding it difficult to sometimes use KOTS because it does not allow them to add custom annotations or env variables to K8s resources. The installer produces a fixed manifest and that then gets applied to the kubernetes cluster. Any changes made forces them to re-apply those changes after an update to Gitpod, which can lead to confusion.
Specific reasons they need to customise / make changes:
Value
Allow Kots to work in more setups, because it can be customised to environment specific circumstances.
Acceptance Criteria
Measurement
Proposed solution
Allow for generic annotations on resources - have a way to set this in the KOTS UI & Installer Config. Then apply together with the installation.
Alternatives considered
Additional Context
Tasks
The text was updated successfully, but these errors were encountered: