Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Kubectl #251

Merged
merged 9 commits into from
Aug 7, 2018
Merged

Kubectl #251

merged 9 commits into from
Aug 7, 2018

Conversation

laverya
Copy link
Member

@laverya laverya commented Aug 6, 2018

What I Did

Added a lifecycle step kubectl that takes a path to be applied and a path to a kubeconfig to use when doing so. If a kubeconfig is supplied, kubectl apply -f PATH --kubeconfig KUBECONFIG is run, otherwise kubectl apply -f PATH is. Output is streamed.

How I Did it

The kubectl command is run with the provided arguments. Template functions within the arguments are evaluated first.

How to verify it

Besides "run it and try", I'm not sure. To the best of my knowledge, this is the first lifecycle step besides message that does not produce any file output, and I am unsure how to test it.

Description for the Changelog

kubectl apply has been added as a lifecycle step.

Picture of a BoatShip (not required but encouraged)

image

@laverya laverya added the wip Work in progress label Aug 6, 2018
laverya added 2 commits August 6, 2018 14:03
also fix dependency cycle caused by merge
added kubectl to ship and integration test images
@laverya laverya removed the wip Work in progress label Aug 7, 2018
@laverya laverya requested a review from areed August 7, 2018 00:02
Copy link
Contributor

@areed areed left a comment

Choose a reason for hiding this comment

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

I think there's a bug around the doneCh

newStderr := stderr.String()
newStdout := stdout.String()

if newStderr != stderrString || newStdout != stdoutString {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to accumulate the full stdout and stderr.

Copy link
Member Author

Choose a reason for hiding this comment

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

At least in my testing, .String() was returning the entirety of the buffer regardless of if it had been read before
I should probably move this to a more explicit "read from buffer" mechanism however

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly what I had looked at myself!

err := cmd.Run()

doneCh <- struct{}{}
<-doneCh
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you were intending for the doneCh in the goroutine to consume the message in 102, then finish its work, and send another message on the doneCh that would be consumed in this line, but there's no guarantee that this won't consume the message in 102 and the goroutine never returns.

return errors.New("A path to apply is required")
}

cmd := k.Kubectl()
Copy link
Contributor

Choose a reason for hiding this comment

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

We did this for helm and terraform because the unit tests run a child process.

@laverya laverya merged commit 6a357a9 into replicatedhq:master Aug 7, 2018
@laverya laverya deleted the kubectl branch August 7, 2018 17:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants