Skip to content

Add a basic ghost package #3381

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

Merged
merged 3 commits into from
Jul 19, 2022
Merged

Add a basic ghost package #3381

merged 3 commits into from
Jul 19, 2022

Conversation

yuwenma
Copy link
Contributor

@yuwenma yuwenma commented Jul 17, 2022

This package is originated from helm chart bitnami/ghost, which uses MariaDB.
By default, the ghost helmchart does not have the ghost, nor does it enable ingress, volumePermissions, networkPolicy, prometheus.

When rendering the ghost helm chart, we include the ghost host (Deployment and PersistentVolumeClaim), as well as the other services (NetworkPolicy Ingress PrometheusRule).

Follow up work is tracked in #3379

Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

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

Some quick comments. Feel free to merge it and address it as a follow up PR.

config.kubernetes.io/local-config: "true"
labels:
app.kubernetes.io/name: ghost
app.kubernetes.io/instance: example
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this label is interesting. We want this to be coming from package-context.data.name. Is this wired currently ? if not, we should take this out ? because example will not represent an instance in our solution.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not wired. The first user that tried to use kpt for an application ran into this. You provided an ApplyReplacements solution on slack.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I was wondering if the current package wires using the ApplyReplacements or Starlark.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not wired. My plan for this package is to start from helm charts to discover as many feature gaps as possible. So this package contains some helm assumptions like configMap to pass in INI file , secret in auto roll deployment, secret reference and usage in livenessProbe and readiness probe.

For this specific value, helm assumes the namespace is "default" (which is convenience because users can install the charts without dealing w/ namespace), and this instance is the helm release name which is used to "differentiate releases for different app". I'm wondering what can be a good equivalent filter on kpt side.

Copy link
Contributor

Choose a reason for hiding this comment

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

On the kpt side, the deployment package name is similar to the release name.

annotations:
config.kubernetes.io/local-config: "true"
data:
name: example
Copy link
Contributor

Choose a reason for hiding this comment

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

so variant constructor pattern isn't support well (or tested :)) for nested packages, so will be interesting to see how this plays out.

Copy link
Contributor

Choose a reason for hiding this comment

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

A user in slack has encountered similar issues using Config Connector subpackages (e.g., CloudSQL).

preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
namespaces:
- "example"
Copy link
Contributor

Choose a reason for hiding this comment

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

Does set-namespace know about this field?

Copy link
Contributor Author

@yuwenma yuwenma Jul 18, 2022

Choose a reason for hiding this comment

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

set-namespace misses this field and also misses the podAffinityTerm.namespaceSelector, which means kustomize does not handle this field either.
I need to do a sanity check across 1.24 core/v1/types.go

name: ghost
annotations:
config.kubernetes.io/local-config: "true"
labels:
Copy link
Contributor

Choose a reason for hiding this comment

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

No spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😞 no spec. I think all custom functionConfig type do not follow the spec status rule. The argument is that those resources won't be deployed to the cluster so it is not a strict spec/status. Skipping spec saves some manual editing.

I'm more happy to add the spec to functionConfig, because it does help answering questions like "what fields & resources a user could be interested in modifying" https://kubernetes.slack.com/archives/C0155NSPJSZ/p1657561360040189

Copy link
Contributor

Choose a reason for hiding this comment

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

This KRM format has at least 4-6 lines of boilerplate even without the spec line (apiVersion, kind, metadata, name, annotations), so we'll want to figure out how to make it easy to generate, such as via the UI and/or a CLI with autocomplete.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or generate it given the function name, if we have a catalog that can map between functions and input types.

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 really like the idea of autogenerating function config for users by only requiring users to provide the function name. Even from my own experience, writing a function config is a big bottleneck to use KRM functions.

Put this as a feature request in #3379

Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

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

We discussed this offline and I captured the notes here.

config.kubernetes.io/local-config: "true"
labels:
app.kubernetes.io/name: ghost
app.kubernetes.io/instance: example
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I was wondering if the current package wires using the ApplyReplacements or Starlark.

@yuwenma yuwenma force-pushed the ghost branch 3 times, most recently from 11448ee to 2040d0d Compare July 19, 2022 00:11
Copy link
Contributor Author

@yuwenma yuwenma left a comment

Choose a reason for hiding this comment

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

Package updated, please take another look @bgrant0607 @droot
Some key changes:

  • Removed secrets and the references (env in pod template, checksum/secret annotation, livenessProbe).
  • Added CRD for PrometheusRule under crds, this should be the only CRD needs to install.
  • Dropped name prefix example- and updated the file names.
  • Dropped the app.kubernetes.io/instance label, I leave a question about the kpt equivalence.
  • Updated README to guide users get, hydrate and deploy the package.

config.kubernetes.io/local-config: "true"
labels:
app.kubernetes.io/name: ghost
app.kubernetes.io/instance: example
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not wired. My plan for this package is to start from helm charts to discover as many feature gaps as possible. So this package contains some helm assumptions like configMap to pass in INI file , secret in auto roll deployment, secret reference and usage in livenessProbe and readiness probe.

For this specific value, helm assumes the namespace is "default" (which is convenience because users can install the charts without dealing w/ namespace), and this instance is the helm release name which is used to "differentiate releases for different app". I'm wondering what can be a good equivalent filter on kpt side.

@bgrant0607
Copy link
Contributor

Thanks. LGTM if the application works.

Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

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

I have a minor comment, but it is good to go.

```bash
export NAMESPACE=<YOUR NAMESPACE>
# make sure the namespace is correct and exists. Otherwise, create the namespace
kubectl create namespace ${NAMESPACE}
Copy link
Contributor

Choose a reason for hiding this comment

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

why can't we add namespace to the package itself ?

If you used helm chart to get the manifests, you can use --create-namespace arg to add it.

That will make the workflow truly declarative.

Copy link
Contributor

Choose a reason for hiding this comment

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

The ability to create a namespace would imply that the app team had cluster admin privilege. It also would bring in the need for the flexibility of the namespace provisioning scenario we've been working on: resource quota, limit range, network policy, etc.

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 have an example namespace blueprint for this, which could be used instead of kubectl create namespace.

Copy link
Contributor

Choose a reason for hiding this comment

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

The ability to create a namespace would imply that the app team had cluster admin privilege. It also would bring in the need for the flexibility of the namespace provisioning scenario we've been working on: resource quota, limit range, network policy, etc.

Aah.. completely missed that. Good pt.

@yuwenma yuwenma merged commit 940e3bb into kptdev:main Jul 19, 2022
chunglu-chou pushed a commit to chunglu-chou/kpt that referenced this pull request Aug 20, 2022
* Add ghost basic package

* update ghost pacakge

* remove set-labels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants