Skip to content

Conversation

@swapnachagam
Copy link

@swapnachagam swapnachagam commented Apr 9, 2025

Overview

Github Issue: {LINK TO ISSUE}

As part of the Hackathon in Autodesk team, I have updated the existing shore render,save and exec functions to be able to generate the k8smanifests. This is a PoC only and still needs to be developed

Summary (required always)

shore render -k k

  • This function will be able to generate the kubernetes manifests based on main.pipeline.jsonnet in a json format which will be again converted to yaml file

**shore save -e d **

  • This function will be generate the kubernetes manifests in a yaml format and save them to folder called generated in the current directory.
  • All the different manifests(iampolicy, iam role) will be saved as separate yaml files, so we can apply them separately if requried

shore exec -e d

  • This function will fetch all the manifests in generated folder and apply them into kubernetes cluster using native k8sclient.
  • I am checking if the format generated is as expected and applying to the cluster
  • If a context is not defined, you will get an error and it will do an apply
  • Also added the capability to delete the manfiests both from the generated folder as well from the kubernetes cluster

shore delete -e d

  • This function will delete all the manifests from generated folder
  • This will also delete the manifests from the kubernetes cluster and returns an error if cluster config is not present

Tested the above scenarios from local using the unit tests which are present using a local kubernetes cluster and some sample files

kind: Namespace
metadata:
  name: example-namespace
  labels:
    environment: development
    team: devops

Test Results

shore render
image

Shore save

image

shore exec

image

shore delete
image

Notes

Checklist

  • My pull request title follows the format <username>/<gh-issue-#number>:<short-description>
  • My code passes existing unit tests
  • My code follows the code style set for the project
  • I have added at least one reviewer for this PR

@swapnachagam swapnachagam requested a review from a team as a code owner April 9, 2025 13:24
@github-actions
Copy link

github-actions bot commented Apr 9, 2025

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@swapnachagam
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

func (s *SpinClient) ExecutePipeline(argsJSON string, stringify bool) (string, *http.Response, error) {

// Check if a valid Kubernetes context is set
cmd := exec.Command("kubectl", "config", "current-context")
Copy link
Collaborator

@dkirillov dkirillov Apr 9, 2025

Choose a reason for hiding this comment

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

Instead of relying on running a CLI command - let's use the native k8s client to do the apply (create) - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/client#example-Client-Create

return "", nil, nil
}

func (s *SpinClient) DeletePipeline(pipelineJSON string) (*http.Response, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Considering we're dropping files and applying a CR - lets also delete both, the dropped files and the CR that gets created on the cluster.

Copy link
Author

Choose a reason for hiding this comment

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

This is now done. I am deleting the folder, files and also CR from the kuberntes. I have tested the same from local


// GetPipeline - Dummy implementation for retrieving a pipeline.
func (s *SpinClient) GetPipeline(application string, pipelineName string) (map[string]interface{}, *http.Response, error) {
s.log.Infof("Retrieving pipeline: application=%s, pipelineName=%s", application, pipelineName)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might be getting a specific resource from the cluster or a specific file from the filesystem.

Will need to check it's usage and how it relates to decide which it should be getting.

Copy link
Author

Choose a reason for hiding this comment

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

I will work on this one later.

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