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

Override app namespace #259

Merged
merged 5 commits into from
Jul 5, 2022
Merged

Override app namespace #259

merged 5 commits into from
Jul 5, 2022

Conversation

stinkyfingers
Copy link
Contributor

Description

Permits overriding an App's namespace. Apps default to the namespace specified by framework.spec.namespace, but there are cases where we don't want namespace tied to framework.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Chore (documentation addition or typo, file relocation)

Testing

  • New tests were added with this PR that prove my fix is effective or that my feature works (describe below this bullet)
  • This change requires no testing (i.e. documentation update)

Documentation

  • All added public packages, funcs, and types have been documented with doc comments
  • I have commented my code, particularly in hard-to-understand areas

Final Checklist:

  • I followed standard GitHub flow guidelines
  • I have performed a self-review of my own code
  • My changes generate no new warnings

Additional Information (omit if empty)

Please include anything else relevant to this PR that may be useful to know.

permits overriding an app's namespace

enable app.spec.namespace on delete
@@ -46,7 +46,7 @@ kind: Deployment
metadata:
annotations:
app: app1
theketch.io/is-shipa: "true"
shipa.io/is-shipa: "true"
Copy link
Contributor

Choose a reason for hiding this comment

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

should we keep theketch.io ?

Copy link
Contributor

Choose a reason for hiding this comment

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

This was changed to theketch.io so a testcase would pass, makes sense to me to keep as theketch.io https://github.com/theketchio/ketch/blob/main/internal/chart/testdata/render_yamls/annotations-patch.yaml#L5

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like a rebase got this caught up.

func (r *AppReconciler) UpdateAppNamespaceLabelsForIstio(ctx context.Context, app *ketchv1.App) error {
var framework ketchv1.Framework
err := r.Client.Get(ctx, types.NamespacedName{Name: app.Spec.Framework, Namespace: app.Namespace}, &framework)
fmt.Println("E", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

let's remove this Println?

if err != nil {
return err
}
namespace.Labels["istio-injection"] = "enabled"
Copy link
Contributor

Choose a reason for hiding this comment

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

should we remove "istio-injection" label for other supported ingresses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified this function to remove this istio-injection label from the namespace when not istio. Also we now reconcile the sidecar.istio.io/inject label on Pods.

namespace.Labels["istio-injection"] = "enabled"
if framework.Spec.IngressController.IngressType != ketchv1.IstioIngressControllerType {
delete(namespace.Labels, "istio-injection")
app.AddLabel(map[string]string{"sidecar.istio.io/inject": "false"}, ketchv1.Target{Kind: "Pod", APIVersion: "v1"})
Copy link
Contributor

Choose a reason for hiding this comment

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

with "sidecar.istio.io/inject": "false" label should we just keep a namespace as it is?
meaning we really don't need to care about a namespace's labels.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I removed all the namespace label changes.

if app.Spec.Labels[i].Target != target {
continue
}
for key := range app.Spec.Labels[i].Apply {
Copy link
Contributor

Choose a reason for hiding this comment

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

that's a very tricky function
should it be

for key := range labels {
    delete(app.Spec.Labels[i].Apply, key)
}

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Changed.

…app.spec.namespace bug; add namespace override for job
@stinkyfingers
Copy link
Contributor Author

I opted to update this to include a namespace override for job too.

@stinkyfingers stinkyfingers merged commit 4de11f3 into main Jul 5, 2022
@stinkyfingers stinkyfingers deleted the app-namespace branch July 5, 2022 15:29
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