kubernetes-sigs / cluster-addons

Addon operators for Kubernetes clusters.
Apache License 2.0
155 stars 47 forks source link

Apply kustomize to hashing configMap's name #46

Closed longkb closed 4 years ago

longkb commented 4 years ago

Signed-off-by: Kim Bao Long longkb@vn.fujitsu.com Co-Authored-By: Nguyen Phuong An AnNP@vn.fujitsu.com

k8s-ci-robot commented 4 years ago

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. :smiley:

k8s-ci-robot commented 4 years ago

[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: - **[OWNERS](https://github.com/kubernetes-sigs/cluster-addons/blob/master/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
longkb commented 4 years ago

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

johnsonj commented 4 years ago

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!
atoato88 commented 4 years ago

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 commented 4 years ago

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.

johnsonj commented 4 years ago

This has been resolved by #50

/close

k8s-ci-robot commented 4 years ago

@johnsonj: Closed this PR.

In response to [this](https://github.com/kubernetes-sigs/cluster-addons/pull/46#issuecomment-639567661): >This has been resolved by #50 > >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
k8s-ci-robot commented 4 years ago

@longkb: PR needs rebase.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.