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

Implement YTT based conventions #4

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

Conversation

katmutua
Copy link
Owner

@katmutua katmutua commented Nov 10, 2022

Implement ytt based conventions

There have been requests from users of conventions to provide the capability to use a templating tool like Carvel ytt so as to easily define conventions.

There are multiple advantages of supporting ytt based conventions and these include

  1. Eliminate the need to create resources required to deploy a conventions webhook server. With ytt based conventions, the convention author will not need to maintain another piece of software that defines the conventions server logic.
  2. Make the process of creating conventions more accessible.
  3. Use Carvel tooling (in this case using ytt templating) which are already deemed as TAP-centric.

Example ClusterpodConvention resource

❯ k get clusterpodconvention.conventions.carto.run/spring-ytt-sample -o yaml

apiVersion: conventions.carto.run/v1alpha1
kind: ClusterPodConvention
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"conventions.carto.run/v1alpha1","kind":"ClusterPodConvention","metadata":{"annotations":{},"name":"spring-ytt-sample"},"spec":{"ytt":{"template":"#@ load(\"@ytt:overlay\", \"overlay\")\n#! apply matcher as you would do using the selector field\n#@overlay/match by=overlay.subset({\"metadata\":{\"name\": \"spring-app\"}})\n---\nspec:\n  containers:\n  #@overlay/match by=overlay.subset({\"name\": \"web2\"})\n  - env:\n    #@overlay/append missing_ok=True\n    - name: LOGGING_LEVEL_COM_EXAMPLE_CONVENTION\n      value: info\n    - name: SERVER_PORT\n      value: \"8443\"\n    - name: SERVER_TOMCAT_MAX_THREADS\n      value: \"20\"\n"}}}
  creationTimestamp: "2022-12-02T16:24:06Z"
  generation: 1
  name: spring-ytt-sample
  resourceVersion: "43371"
  uid: 3d4a9293-9866-4436-82ae-e2d2a862ead5
spec:
  priority: Normal
  selectorTarget: PodTemplateSpec
  ytt:
    template: |
      #@ load("@ytt:overlay", "overlay")
      #! apply matcher as you would do using the selector field
      #@overlay/match by=overlay.subset({"metadata":{"name": "spring-app"}})
      ---
      spec:
        containers:
        #@overlay/match by=overlay.subset({"name": "web2"})
        - env:
          #@overlay/append missing_ok=True
          - name: LOGGING_LEVEL_COM_EXAMPLE_CONVENTION
            value: info
          - name: SERVER_PORT
            value: "8443"
          - name: SERVER_TOMCAT_MAX_THREADS
            value: "20"

Which issue(s) this PR fixes

Fixes # 58

Describe testing done for PR

TBD

Additional information or special notes for your reviewer

< TO DO >

@katmutua katmutua marked this pull request as draft December 1, 2022 17:02
@katmutua katmutua force-pushed the ytt-based-conventions branch 3 times, most recently from d0d2595 to bcf0126 Compare December 2, 2022 21:01
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.

1 participant