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

feat(Helm): Update Loki Helm chart for restricted environments #14440

Merged

Conversation

davidham
Copy link
Contributor

@davidham davidham commented Oct 9, 2024

What this PR does / why we need it:
We are attempting to deploy this chart, with Enterprise enabled and in distributed mode, to a restricted k8s environment. The two main restrictions driving this PR are:

  • we can't deploy any cluster-level resources, only namespaced ones
  • we don't have the ability to delete pods in the live environment
  • pods have no permissions in the k8s namespace except what is granted to them with a Role

With this in mind, I am proposing the following changes:

Statefulsets for ingester and index-gateway
The change here is to make the spec.updateStrategy.type configurable, and to default to RollingUpdate.

Enterprise tokengen
For this change, if enterprise and tokengen are enabled, and rbac.namespaced is true, the chart will render a Role and RoleBinding. If rbac.namespaced is false, it will render a ClusterRole and ClusterRoleBinding.

Which issue(s) this PR fixes:
n/a

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

Changed the behavior so that if `.Values.rbac.namespaced` is enabled, it creates a Role instead of a ClusterRole for tokengen.
@CLAassistant
Copy link

CLAassistant commented Oct 9, 2024

CLA assistant check
All committers have signed the CLA.

This comment has been minimized.

@pull-request-size pull-request-size bot added size/M and removed size/S labels Oct 9, 2024
@github-actions github-actions bot added the type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories label Oct 9, 2024

This comment has been minimized.

@davidham davidham changed the title feat(Helm): Updates for restricted environments feat(Helm): Update Loki Helm chart for restricted environments Oct 9, 2024
@davidham davidham marked this pull request as ready for review October 9, 2024 20:35
@davidham davidham requested a review from a team as a code owner October 9, 2024 20:35

This comment has been minimized.

Copy link
Contributor

@DylanGuedes DylanGuedes left a comment

Choose a reason for hiding this comment

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

Thank you for your PR ❤️
Asked a few questions below, my only concern with the current approach is that it makes it difficult to configure other attributes (that not the type) and that we're making a small change to the indexGateway strategy and I'm not sure if that is a breaking change or not.

Comment on lines 43 to 44
updateStrategy:
type: OnDelete
type: {{ .Values.ingester.updateStrategy }}
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto: could you please make the whole updateStrategy configurable otherwise users won't be able to set the rollingUpdate

Comment on lines 43 to 44
updateStrategy:
type: OnDelete
type: {{ .Values.ingester.updateStrategy }}
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Comment on lines 43 to 44
updateStrategy:
type: OnDelete
type: {{ .Values.ingester.updateStrategy }}
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@@ -18,8 +18,7 @@ spec:
{{- end }}
podManagementPolicy: Parallel
updateStrategy:
rollingUpdate:
partition: 0
type: {{ .Values.ingester.updateStrategy }}
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@@ -2313,6 +2315,8 @@ indexGateway:
# -- Set the optional grpc service protocol. Ex: "grpc", "http2" or "https"
appProtocol:
grpc: ""
# -- UpdateStrategy for the StatefulSet. One of 'OnDelete' or 'RollingUpdate'.
updateStrategy: RollingUpdate
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto: after making the changes to make the updateStrategy configurable, in case setting partition: 0 is different than the default, can you add it to this values.yaml, to not make a breaking change?

This comment has been minimized.

# -- One of 'OnDelete' or 'RollingUpdate'
type: RollingUpdate
# -- Optional for updateStrategy.type=RollingUpdate. See [Partitioned rolling updates](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#partitions) in the StatefulSet docs for details.
# rollingUpdate:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you specify a spec.updateStrategy.rollingUpdate block in values.yaml, you have to null it out if you want to set spec.updateStrategy.type=OnDelete. But I think partition: 0 is a no-op in any case.

Copy link
Contributor

Kubernetes Manifest Diff Summary

Scenario: default-single-binary-values (Added: 0, Modified: 4, Removed: 0)

Summary:

  • Added: 0

  • Modified: 4

  • Removed: 0

Added Files

No added files

Modified Files

loki/templates/index-gateway/statefulset-index-gateway.yaml
*** /home/runner/work/loki/loki/output/base/default-single-binary-values/loki/templates/index-gateway/statefulset-index-gateway.yaml	2024-10-10 10:24:09.264117944 +0000
--- /home/runner/work/loki/loki/output/pr/default-single-binary-values/loki/templates/index-gateway/statefulset-index-gateway.yaml	2024-10-10 10:24:12.160095354 +0000
***************
*** 14,21 ****
 spec:
 replicas: 2
 updateStrategy:
! rollingUpdate:
! partition: 0
 serviceName: loki-test-chart-name-index-gateway-headless
 revisionHistoryLimit: 10
 selector:
--- 14,20 ----
 spec:
 replicas: 2
 updateStrategy:
! type: RollingUpdate
 serviceName: loki-test-chart-name-index-gateway-headless
 revisionHistoryLimit: 10
 selector:
loki/templates/ingester/statefulset-ingester-zone-c.yaml
*** /home/runner/work/loki/loki/output/base/default-single-binary-values/loki/templates/ingester/statefulset-ingester-zone-c.yaml	2024-10-10 10:24:09.264117944 +0000
--- /home/runner/work/loki/loki/output/pr/default-single-binary-values/loki/templates/ingester/statefulset-ingester-zone-c.yaml	2024-10-10 10:24:12.160095354 +0000
***************
*** 30,36 ****
 name: ingester-zone-c
 rollout-group: ingester
 updateStrategy:
! type: OnDelete
 template:
 metadata:
 annotations:
--- 30,36 ----
 name: ingester-zone-c
 rollout-group: ingester
 updateStrategy:
! type: RollingUpdate
 template:
 metadata:
 annotations:
loki/templates/ingester/statefulset-ingester-zone-b.yaml
*** /home/runner/work/loki/loki/output/base/default-single-binary-values/loki/templates/ingester/statefulset-ingester-zone-b.yaml	2024-10-10 10:24:09.264117944 +0000
--- /home/runner/work/loki/loki/output/pr/default-single-binary-values/loki/templates/ingester/statefulset-ingester-zone-b.yaml	2024-10-10 10:24:12.160095354 +0000
***************
*** 30,36 ****
 name: ingester-zone-b
 rollout-group: ingester
 updateStrategy:
! type: OnDelete
 template:
 metadata:
 annotations:
--- 30,36 ----
 name: ingester-zone-b
 rollout-group: ingester
 updateStrategy:
! type: RollingUpdate
 template:
 metadata:
 annotations:
loki/templates/ingester/statefulset-ingester-zone-a.yaml
*** /home/runner/work/loki/loki/output/base/default-single-binary-values/loki/templates/ingester/statefulset-ingester-zone-a.yaml	2024-10-10 10:24:09.264117944 +0000
--- /home/runner/work/loki/loki/output/pr/default-single-binary-values/loki/templates/ingester/statefulset-ingester-zone-a.yaml	2024-10-10 10:24:12.160095354 +0000
***************
*** 30,36 ****
 name: ingester-zone-a
 rollout-group: ingester
 updateStrategy:
! type: OnDelete
 template:
 metadata:
 annotations:
--- 30,36 ----
 name: ingester-zone-a
 rollout-group: ingester
 updateStrategy:
! type: RollingUpdate
 template:
 metadata:
 annotations:

Removed Files

No removed files

Scenario: default-values (Added: 0, Modified: 0, Removed: 0)

Summary:

  • Added: 0

  • Modified: 0

  • Removed: 0

Added Files

No added files

Modified Files

No modified files

Removed Files

No removed files

Scenario: ingress-values (Added: 0, Modified: 0, Removed: 0)

Summary:

  • Added: 0

  • Modified: 0

  • Removed: 0

Added Files

No added files

Modified Files

No modified files

Removed Files

No removed files

Scenario: legacy-monitoring-values (Added: 0, Modified: 0, Removed: 0)

Summary:

  • Added: 0

  • Modified: 0

  • Removed: 0

Added Files

No added files

Modified Files

No modified files

Removed Files

No removed files

Scenario: simple-scalable-aws-kube-irsa-values (Added: 0, Modified: 0, Removed: 0)

Summary:

  • Added: 0

  • Modified: 0

  • Removed: 0

Added Files

No added files

Modified Files

No modified files

Removed Files

No removed files

@DylanGuedes DylanGuedes merged commit adc7538 into main Oct 10, 2024
64 checks passed
@DylanGuedes DylanGuedes deleted the feature/helm-chart-updates-for-restricted-environments branch October 10, 2024 10:39
trevorwhitney pushed a commit that referenced this pull request Oct 10, 2024
**Statefulsets for ingester and index-gateway**
The change here is to make the `spec.updateStrategy.type` configurable, and to default to `RollingUpdate`.

**Enterprise tokengen**
For this change, if `enterprise` and `tokengen` are enabled, and `rbac.namespaced` is true, the chart will render a `Role` and `RoleBinding`. If `rbac.namespaced` is false, it will render a `ClusterRole` and `ClusterRoleBinding`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/helm size/M type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants