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

Apply kustomize to hashing configMap's name #46

Closed

Conversation

longkb
Copy link

@longkb longkb commented Mar 4, 2020

Signed-off-by: Kim Bao Long [email protected]
Co-Authored-By: Nguyen Phuong An [email protected]

Signed-off-by: Kim Bao Long <[email protected]>
Co-Authored-By: Nguyen Phuong An <[email protected]>
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 4, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @longkb!

It looks like this is your first PR to kubernetes-sigs/cluster-addons 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-addons has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Mar 4, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: longkb
To complete the pull request process, please assign dholbach
You can assign the PR to them by writing /assign @dholbach in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@longkb
Copy link
Author

longkb commented Mar 10, 2020

@johnsonj : This PR is pushed by following the PR #66 in kubebuilder declarative partern.
Please give me your helpful comments for this PR :)

@johnsonj
Copy link
Contributor

Thanks for the ping @longkb ! The kustomization looks good and is inline with what I'd expect.

A few points:

  1. How does the user configure the Corefile? I don't think there's any harm in baking it in today, but for the future I would expect that we'd a property (or multiple?) to the CoreDNS Addon CRD to configure this. Eg:
apiVersion: addons.k8s.io/v1alpha1
kind: CoreDNS
metadata:
  name: default
  namespace: kube-system
spec:
  channel: stable
  corefile: |
    // .. my corefile!

The operator could then use a declarative.ManifestOperation to replace the contents of the configmap with this value (or default it). The transforms are applied before kustomize build runs, so this would still give us the hashing/rollout of Corefile changes.

  1. You should replace the current manifest with this. We don't need 1.3.1 and 1.3.1-kustomize. Let's make kustomize the default!

Copy link
Contributor

@atoato88 atoato88 left a comment

Choose a reason for hiding this comment

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

In static review, I have a few comments.

@@ -0,0 +1,17 @@
.:53 {
errors
Copy link
Contributor

Choose a reason for hiding this comment

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

in 1.3.1/manifest.yaml, there are 4 spaces for indent.
Here is 8 spaces, is it ok?

@@ -5,3 +5,5 @@ require (
k8s.io/apimachinery v0.0.0-20190719140911-bfcf53abc9f8
k8s.io/code-generator v0.0.0-20190717022600-77f3a1fe56bb // indirect
)

go 1.13
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this PR related to installer's code?
Should we include this change in this PR?

@atoato88
Copy link
Contributor

I faced 2 types of errors with execution of this PR's code.
Here are logs in the time.

Type 1.

I0311 10:45:42.393243   18739 reconciler.go:113]  "msg"="reconciling" "object"="kube-system/default" 
I0311 10:45:42.393275   18739 types.go:98]  "msg"="loading channel" "base"="./channels" "channel"="stable" 
I0311 10:45:42.393473   18739 fs.go:93]  "msg"="resolved version from channel" "channel"="stable" "version"="1.3.1-kustomize" 
I0311 10:45:42.393492   18739 types.go:125]  "msg"="loading package" "package"="coredns" 
I0311 10:45:42.493834   18739 coredns_controller.go:141] determined ClusterIP for kube-dns should be "10.96.0.10"
E0311 10:45:42.493987   18739 objects.go:334]  "msg"="error decoding object" "error"="error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type map[string]interface {}" "yaml"=".:53 {\n        errors\n        health\n        kubernetes cluster.local in-addr.arpa ip6.arpa {\n            pods insecure\n            upstream\n            fallthrough in-addr.arpa ip6.arpa\n            ttl 30\n        }\n        prometheus :9153\n        forward . /etc/resolv.conf\n        cache 30\n        loop\n        reload\n        loadbalance\n    }\n\n\n" 
E0311 10:45:42.494016   18739 reconciler.go:215]  "msg"="error parsing manifest" "error"="error decoding object: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type map[string]interface {}"  
E0311 10:45:42.494030   18739 reconciler.go:117]  "msg"="building deployment objects" "error"="error decoding object: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type map[string]interface {}"  
E0311 10:45:42.494087   18739 controller.go:258] controller-runtime/controller "msg"="Reconciler error" "error"="error building deployment objects: error decoding object: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type map[string]interface {}"  "controller"="coredns-controller" "request"={"Namespace":"kube-system","Name":"default"}
I0311 10:45:43.494248   18739 reconciler.go:113]  "msg"="reconciling" "object"="kube-system/default" 

It says "error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type map[string]interface {}".
I think It is an error against coredns/channels/packages/coredns/1.3.1-kustomize/Corefile, because of Corefile isn't JSON format.
But Corefile is not JSON format originally.

Type 2.

I0311 10:57:36.364143   32633 coredns_controller.go:141] determined ClusterIP for kube-dns should be "10.96.0.10"
E0311 10:57:36.364315   32633 objects.go:334]  "msg"="error decoding object" "error"="error unmarshaling JSON: while decoding JSON: Object 'Kind' is missing in '{\"configMapGenerator\":[{\"files\":[\"Corefile\"],\"name\":\"coredns\",\"namespace\":\"kube-system\"}],\"generatorOptions\":{\"labels\":{\"addonmanager.kubernetes.io/mode\":\"EnsureExists\"}},\"resources\":[\"services.yaml\",\"deployment.yaml\"]}'" "yaml"="# resource definition in YAML.  These are the resource\n# files that kustomize reads, modifies and emits as a\n# YAML string, with resources separated by document\n# markers (\"---\").\nresources:\n- services.yaml\n- deployment.yaml\nconfigMapGenerator:\n- name: coredns\n  namespace: kube-system\n  files:\n  - Corefile\ngeneratorOptions:\n  labels:\n      addonmanager.kubernetes.io/mode: EnsureExists\n" 
E0311 10:57:36.364343   32633 reconciler.go:215]  "msg"="error parsing manifest" "error"="error decoding object: error unmarshaling JSON: while decoding JSON: Object 'Kind' is missing in '{\"configMapGenerator\":[{\"files\":[\"Corefile\"],\"name\":\"coredns\",\"namespace\":\"kube-system\"}],\"generatorOptions\":{\"labels\":{\"addonmanager.kubernetes.io/mode\":\"EnsureExists\"}},\"resources\":[\"services.yaml\",\"deployment.yaml\"]}'"  
E0311 10:57:36.364367   32633 reconciler.go:117]  "msg"="building deployment objects" "error"="error decoding object: error unmarshaling JSON: while decoding JSON: Object 'Kind' is missing in '{\"configMapGenerator\":[{\"files\":[\"Corefile\"],\"name\":\"coredns\",\"namespace\":\"kube-system\"}],\"generatorOptions\":{\"labels\":{\"addonmanager.kubernetes.io/mode\":\"EnsureExists\"}},\"resources\":[\"services.yaml\",\"deployment.yaml\"]}'"  
E0311 10:57:36.364416   32633 controller.go:258] controller-runtime/controller "msg"="Reconciler error" "error"="error building deployment objects: error decoding object: error unmarshaling JSON: while decoding JSON: Object 'Kind' is missing in '{\"configMapGenerator\":[{\"files\":[\"Corefile\"],\"name\":\"coredns\",\"namespace\":\"kube-system\"}],\"generatorOptions\":{\"labels\":{\"addonmanager.kubernetes.io/mode\":\"EnsureExists\"}},\"resources\":[\"services.yaml\",\"deployment.yaml\"]}'"  "controller"="coredns-controller" "request"={"Namespace":"kube-system","Name":"default"}
I0311 10:57:37.364607   32633 reconciler.go:113]  "msg"="reconciling" "object"="kube-system/default" 

It says error decoding object: error unmarshaling JSON: while decoding JSON: Object 'Kind' is missing ....
This is an error against coredns/channels/packages/coredns/1.3.1-kustomize/kustomization.yaml.
kustomization.yaml is valid for JSON format, but it doesn't include Kind key in content.

Reason for these error is that reading all files as JSON format and should have Kind key something, if so, it seems a bug in kubernetes-sigs/kubebuilder-declarative-pattern side, right?

related code: 1 2

@johnsonj
Copy link
Contributor

johnsonj commented Mar 17, 2020

Thanks for investigating these issues @atoato88 - I agree there's changes needed in the library to support this, linked your comment in kubernetes-sigs/kubebuilder-declarative-pattern#56 for context.

@vanou vanou mentioned this pull request Apr 2, 2020
4 tasks
@johnsonj
Copy link
Contributor

johnsonj commented Jun 5, 2020

This has been resolved by #50

/close

@k8s-ci-robot
Copy link
Contributor

@johnsonj: Closed this PR.

In response to this:

This has been resolved by #50

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 5, 2020
@k8s-ci-robot
Copy link
Contributor

@longkb: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants