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

Switch to use libchart approach to avoid code duplication #124

Merged
merged 1 commit into from
Apr 23, 2021

Conversation

ekarlso
Copy link
Contributor

@ekarlso ekarlso commented Apr 5, 2021

No description provided.

@ekarlso ekarlso changed the title vault-injector: Supports only admissions of v1beta1 Switch to use libchart approach to avoid code duplication Apr 5, 2021
@ekarlso ekarlso force-pushed the switch-to-libchart branch 5 times, most recently from 028a946 to 14c580d Compare April 5, 2021 18:29
@bjorges bjorges requested review from bjorges and tomsolem April 5, 2021 18:44
@ekarlso ekarlso force-pushed the switch-to-libchart branch 7 times, most recently from 9782bd6 to 1a30741 Compare April 5, 2021 22:46
Copy link
Contributor

@ahm81 ahm81 left a comment

Choose a reason for hiding this comment

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

sjekk også i linje 7 på java/templates/NOTES.txt

dotnet/templates/NOTES.txt Outdated Show resolved Hide resolved
golang/templates/NOTES.txt Outdated Show resolved Hide resolved
nodejs/templates/NOTES.txt Outdated Show resolved Hide resolved
web/templates/NOTES.txt Outdated Show resolved Hide resolved
@Haavare
Copy link

Haavare commented Apr 7, 2021

When the comments are resolved this looks good

Copy link
Contributor

@ahm81 ahm81 left a comment

Choose a reason for hiding this comment

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

@ekarlso Etter å ha sjekket nøyere etter så lurer jeg på om du generer duplikater siden du både har templates mappen for hvert språk og har tillegg templates mappen med samme tingene i libchart

@Haavare
Copy link

Haavare commented Apr 13, 2021

I can't se any duplicated *.yaml files, the _*.tpl files will not create files of their own.

@Haavare
Copy link

Haavare commented Apr 13, 2021

@ekarlso you have to run helm dependency update to import the libchart tar file into /charts

helm package bundles the tar file

@Haavare
Copy link

Haavare commented Apr 13, 2021

here is a example of helm template libchart-test ./dotnet/ after importing the libchar tar file:

---
# Source: dotnet/templates/service-account.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: libchart-test-dotnet
  namespace: marine-resources-prod
  labels:
    helm.sh/chart: dotnet-9.0.0

    app.kubernetes.io/name: libchart-test
    app.kubernetes.io/instance: libchart-test

    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/part-of: libchart-test
    app.kubernetes.io/component: libchart-test
---
# Source: dotnet/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: libchart-test
  namespace: marine-resources-prod
  labels:
    helm.sh/chart: dotnet-9.0.0

    app.kubernetes.io/name: libchart-test
    app.kubernetes.io/instance: libchart-test

    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/part-of: libchart-test
    app.kubernetes.io/component: libchart-test
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: 8080
      protocol: TCP
      name: http

  selector:

    app.kubernetes.io/name: libchart-test
    app.kubernetes.io/instance: libchart-test
---
# Source: dotnet/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: libchart-test
  namespace: marine-resources-prod
  labels:
    helm.sh/chart: dotnet-9.0.0

    app.kubernetes.io/name: libchart-test
    app.kubernetes.io/instance: libchart-test

    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/part-of: libchart-test
    app.kubernetes.io/component: libchart-test
spec:
  replicas: 1
  selector:
    matchLabels:

      app.kubernetes.io/name: libchart-test
      app.kubernetes.io/instance: libchart-test
  template:
    metadata:
      labels:
        helm.sh/chart: dotnet-9.0.0

        app.kubernetes.io/name: libchart-test
        app.kubernetes.io/instance: libchart-test

        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/part-of: libchart-test
        app.kubernetes.io/component: libchart-test
    spec:

      serviceAccountName: libchart-test-dotnet
      securityContext:
        runAsNonRoot: true
      containers:
        - name: dotnet
          image: ":"
          imagePullPolicy: Always
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP

          livenessProbe:
            httpGet:
              path: /
              port: 8080
            initialDelaySeconds: 15
            timeoutSeconds: 15
            periodSeconds: 15
          readinessProbe:
            httpGet:
              path: /
              port: 8080
            initialDelaySeconds: 15
            timeoutSeconds: 15
            periodSeconds: 15
          env:
          resources:

            {}
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 1
              podAffinityTerm:
                topologyKey: "kubernetes.io/hostname"
                labelSelector:
                  matchLabels:

                    app.kubernetes.io/name: libchart-test
                    app.kubernetes.io/instance: libchart-test
---
# Source: dotnet/templates/servicemonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: libchart-test
  namespace: marine-resources-prod
  labels:
    helm.sh/chart: dotnet-9.0.0

    app.kubernetes.io/name: libchart-test
    app.kubernetes.io/instance: libchart-test

    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/part-of: libchart-test
    app.kubernetes.io/component: libchart-test
    prometheus: default
spec:
  selector:
    matchLabels:

      app.kubernetes.io/name: libchart-test
      app.kubernetes.io/instance: libchart-test
  endpoints:
  - path: /metrics
    interval: 15s
    targetPort: 8080
    honorLabels: true

I do not know if this is a good example

@Haavare
Copy link

Haavare commented Apr 13, 2021

I think this is a good examle of a situation where Architecture Decision Records would make sense to have:
https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions

At the moment I am not sure why libchart is considered less complex than maintaining separate charts

@ekarlso
Copy link
Contributor Author

ekarlso commented Apr 15, 2021

I think this is a good examle of a situation where Architecture Decision Records would make sense to have:
https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions

At the moment I am not sure why libchart is considered less complex than maintaining separate charts

Because now implementing a change or a common component is at least common across them all ;)

Whether we should actually have seperate charts for java, dotnet, or whatever language you think if is a better valid question in my mind.

@Haavare
Copy link

Haavare commented Apr 15, 2021

Yes, I actually thought you all decided only the web chart was necessary two years ago

@Haavare
Copy link

Haavare commented Apr 15, 2021

There are namespace in some but not all templates, I do not think we need them, but could we be consistent either or.

@ekarlso ekarlso force-pushed the switch-to-libchart branch 3 times, most recently from f66680b to 03531ab Compare April 18, 2021 14:24
@ekarlso
Copy link
Contributor Author

ekarlso commented Apr 18, 2021

There are namespace in some but not all templates, I do not think we need them, but could we be consistent either or.

Removed namespaces and now and added policy to keep it removed :

Copy link

@Haavare Haavare left a comment

Choose a reason for hiding this comment

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

You check if it is a statefulset twice, on include and define. I think that is fine.
I am not familiar with the Istio templates, so I just checke spelling.
Otherwise did you see my comment on labelSelectors? That is the only thing I have left, great work!

dotnet/templates/NOTES.txt Outdated Show resolved Hide resolved
dotnet/values.yaml Outdated Show resolved Hide resolved
golang/values.yaml Outdated Show resolved Hide resolved
libchart/templates/_helpers.tpl Outdated Show resolved Hide resolved
golang/templates/cm-certificate.yaml Show resolved Hide resolved
.gitmodules Outdated Show resolved Hide resolved
web/values.yaml Show resolved Hide resolved
@ekarlso
Copy link
Contributor Author

ekarlso commented Apr 21, 2021

You check if it is a statefulset twice, on include and define. I think that is fine.
I am not familiar with the Istio templates, so I just checke spelling.
Otherwise did you see my comment on labelSelectors? That is the only thing I have left, great work!

Where's this?

* Add ability to pass command + args
* Add hpa
@ahm81
Copy link
Contributor

ahm81 commented Apr 22, 2021

Good work @ekarlso!

@Haavare
Copy link

Haavare commented Apr 22, 2021

You check if it is a statefulset twice, on include and define. I think that is fine.
I am not familiar with the Istio templates, so I just checke spelling.
Otherwise did you see my comment on labelSelectors? That is the only thing I have left, great work!

Where's this?

Looks like you have changed it, all good

@ekarlso ekarlso merged commit 863e3f1 into master Apr 23, 2021
@ekarlso ekarlso deleted the switch-to-libchart branch April 23, 2021 06:12
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