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

Implemented controller for NATS CR #19

Merged
merged 14 commits into from
Apr 13, 2023

Conversation

mfaizanse
Copy link
Member

Description

Changes proposed in this pull request:

  • Implemented controller for NATS CR

Related issue(s)

@kyma-bot kyma-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 30, 2023
@mfaizanse mfaizanse linked an issue Mar 30, 2023 that may be closed by this pull request
4 tasks
@mfaizanse mfaizanse marked this pull request as ready for review April 6, 2023 08:13
@mfaizanse mfaizanse requested a review from a team as a code owner April 6, 2023 08:13
@kyma-bot kyma-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 6, 2023
@@ -65,7 +65,7 @@ vet: ## Run go vet against code.
go vet ./...

.PHONY: test
test: manifests go-gen generate fmt vet envtest lint-thoroughly ## Run tests.
test: manifests generate fmt vet envtest lint-thoroughly ## Run tests.
Copy link
Member Author

Choose a reason for hiding this comment

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

go-gen is already called inside generate

Dockerfile Outdated
@@ -30,6 +30,8 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o ma
FROM gcr.io/distroless/static:nonroot
LABEL source = git@github.com:kyma-project/nats-manager.git

ARG NATS_CHARTS_DIR="/resources/nats"
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this used?

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

@@ -22,7 +22,7 @@ limitations under the License.
package v1alpha1

import (
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Copy link
Contributor

Choose a reason for hiding this comment

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

A bit strange code generation 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

no idea, its gone now somehow.

@@ -69,6 +69,9 @@ spec:
image: controller:latest
imagePullPolicy: Always
name: manager
env:
- name: NATS_CHARTS_DIR
Copy link
Contributor

Choose a reason for hiding this comment

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

NATS_CHARTS_DIR -> NATS_CHART_DIR

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

setupLog.Error(err, "unable to get configs from env")
os.Exit(1)
}

// @TODO: Re-check logger setup and init
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this todo still relevant?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I added a todo here #8

Comment on lines +8 to +55
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- secrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- services
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps/v1
resources:
- statefulsets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
Copy link
Contributor

Choose a reason for hiding this comment

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

Too much power, do we really need them all?

Copy link
Member Author

Choose a reason for hiding this comment

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

It will be re-visited in this ticket: #21

Comment on lines +127 to +128
// Check if istio is enabled in cluster
istioExists, err := r.kubeClient.DestinationRuleCRDExists(ctx)
Copy link
Contributor

@marcobebway marcobebway Apr 6, 2023

Choose a reason for hiding this comment

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

As per the comment, this checks if istio is enabled in the cluster or not. I'm not sure if that's the right way to do it. I think we need to check if istio as a Kyma module is ready or not, by checking istio CR status.state. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, the only thing we care about is the DestinationRule exists or not, so we can create CR for it. Checking the kyma module will make it more coupled to Istio module. Also, what if user has it own deployment of istio resources.


// @TODO: Provide the overrides in component.Configuration
instance.Configuration = map[string]interface{}{
"istio.enabled": istioExists,
Copy link
Contributor

@marcobebway marcobebway Apr 6, 2023

Choose a reason for hiding this comment

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

What will this do in case of true/false?

Copy link
Member Author

Choose a reason for hiding this comment

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

If true, then it will create DestinationRule CR.

// @TODO: Provide the overrides in component.Configuration
instance.Configuration = map[string]interface{}{
"istio.enabled": istioExists,
"auth.rotatePassword": accountSecret == nil, // do not recreate secret if it exists
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure this will create a secret that matches the accountSecretName and nats.Namespace?

Copy link
Member Author

Choose a reason for hiding this comment

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

The name format is the same in NATS helm chart. If someone changes the name format in helm, the pre-main tests should fail.

func (r *Reconciler) loggerWithNATS(nats *natsv1alpha1.NATS) *zap.SugaredLogger {
return r.logger.With(
"kind", nats.GetObjectKind().GroupVersionKind().Kind,
"version", nats.GetGeneration(),
Copy link
Contributor

Choose a reason for hiding this comment

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

"version" -> "generation"

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@kyma-bot kyma-bot added the lgtm Looks good to me! label Apr 13, 2023
@mfaizanse
Copy link
Member Author

/cla-recheck

@mfaizanse mfaizanse merged commit 7e080fb into kyma-project:main Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Looks good to me! size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle external charts provided by nats_io
3 participants