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

Update examples to generate kubernetes compliant deployments #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Pokom
Copy link

@Pokom Pokom commented Sep 7, 2022

As I work through the examples, I like getting some hands on experience deploying the changes to a kubernetes cluster.
I've created a local kind cluster to test changes against by executing the following commend:

jsonnet example1.jsonnet | k apply -f -

Issues resolved:

  • selector and labels are missing(k8s rejects deployment)
  • examples 4/6/7 nested the deployment in a deployment object which k8s will reject
  • httpd:2.5 does not exist 😄, so I changed it to 2.3 for the default and called withImage('httpd:2.4')

I ignored the following:

  • example5.jsonnet isn't referenced, can probably be deleted?
  • updated pitfall examples

I'll submit separate PR's later lessons as I get to them. Overall, I found the first lesson to be pretty clear where the value add is with jsonnet and liked how you introduced mixins and other concepts.

@Pokom Pokom marked this pull request as ready for review September 7, 2022 20:44
@Pokom Pokom changed the title WIP: Update examples to generate kubernetes compliant deployments Update examples to generate kubernetes compliant deployments Sep 8, 2022
Copy link
Member

@Duologic Duologic left a comment

Choose a reason for hiding this comment

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

I wrote a jsonnet lib a while ago that can extract kubernetes objects from a json: https://gist.github.com/Duologic/d179134cf86bbcda7a59ac3cf000876e

This is similar to how Tanka works except it doesn't need Tanka. 🤷

Let's brainstorm on how we can integrate this into the course, I bet it might be useful in the context of this PR.

Comment on lines -10 to -11
deployment: {
apiVersion: 'apps/v1',
Copy link
Member

@Duologic Duologic Sep 29, 2022

Choose a reason for hiding this comment

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

The nested deployment object is of importance to write idiomatic jsonnet, it allows for multiple objects to exist within a single output and referring to them in functions later.

If we'd like to pipe the jsonnet output to kubectl, I think we need to write a wrapper script that extracts the kubernetes objects into a list that is safe to be applied.

@Pokom
Copy link
Author

Pokom commented Sep 29, 2022

Thanks for the feedback! At the time, I didn't realize the importance of the nested deployment object. I think it would be reasonable to leave the deployment object in to ensure it's idiomatic jsonnet, otherwise that defeats the purpose of the course.

Let me try to fiddle with the script you linked and see if I can update the example to include a snippet on how to pipe the output into kubectl so that it can run.

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.

2 participants