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

Support k8s Deployment in play kube #6256

Merged

Conversation

theunrealgeek
Copy link
Contributor

This PR is adding support for Deployment k8s Kind in addition to the already supported Pod kind and is in response to #4093

Deployment kinds generally just spit out one or more Pods from a template spec. Hence I have reused most of the existing code for Pod and just created multiple of these dictated by the replica count specified in the Deployment YAML.

The only breaking change in this PR is that container names from play kube now have the name of the pod prefixed to them since podman needs unique container names overall and not unique container names per-pod as is the expectation from Kubernetes.

@openshift-ci-robot openshift-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 18, 2020
@openshift-ci-robot
Copy link
Collaborator

Hi @theunrealgeek. Thanks for your PR.

I'm waiting for a containers member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@rhatdan
Copy link
Member

rhatdan commented May 18, 2020

Thanks @theunrealgeek
This looks like it breaks a bunch of tests?
@haircommander @baude @mheon @giuseppe @umohnani8 @mrunalp PTAL

@rhatdan rhatdan changed the title Support k8s Deploymnt in play kube Support k8s Deployment in play kube May 18, 2020
@haircommander
Copy link
Collaborator

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 18, 2020
fmt.Printf("Pod:\n%s\n", report.Pod)
switch len(report.Pods) {
case 0:
return nil
Copy link
Member

Choose a reason for hiding this comment

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

Hm. Are there cases where containers could be made, but not pods? We might want to make 0 print nothing but not return yet

Copy link
Collaborator

Choose a reason for hiding this comment

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

I actually disagree, there really shouldn't be a case containers are created and pods are not. I think return early here if no printing is needed

@haircommander
Copy link
Collaborator

haircommander commented May 18, 2020

this looks awesome @theunrealgeek ! can you add some tests in the style of the tests in test/e2e/play_kube_test.go?

@@ -359,6 +414,11 @@ func kubeContainerToCreateConfig(ctx context.Context, containerYAML v1.Container
containerConfig.Image = containerYAML.Image
containerConfig.ImageID = newImage.ID()
containerConfig.Name = containerYAML.Name

if podName != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe fail here if podName is not specified?

@theunrealgeek
Copy link
Contributor Author

this looks awesome @theunrealgeek ! can you add some tests in the style of the tests in test/e2e/play_kube_test.go?

Didn't realise there were tests for this, I'll add some new tests for the new stuff and fix any existing ones that break.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 23, 2020
@rhatdan
Copy link
Member

rhatdan commented May 23, 2020

@theunrealgeek Please rebase this PR

@theunrealgeek
Copy link
Contributor Author

I'm done fixing the existing tests and addressing most of the review comments. I need to add a few more tests with a Deployment YAML and will hopefully update the PR with all of this tomorrow

@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 30, 2020
@theunrealgeek
Copy link
Contributor Author

@haircommander Can you please take a look at this again ? I've addressed most of the comments. There are still some failing CI tests which don't seem related to anything I have touched, but if they are, please let me know and I'll take a look at them.

spec:
hostname: unknown
`

var yamlTemplate = `
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I would probably change this to podYAMLTemplate now


return nil
}

func generateKubeYaml(pod *Pod, fileName string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

similarly, this should probably generatePodKubeYaml

Copy link
Collaborator

Choose a reason for hiding this comment

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

also, if there's any redundancy in this function with generateDeploymentKubeYaml, It'd be ideal if the similarities could be put in a function. I see you've made writeYAML, but haven't used it in generateKubeYaml


return nil
}

func generateKubeYaml(pod *Pod, fileName string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

second nit for this line: we should stick to either YAML or Yaml. I don't care which, but if you'd prefer to use YAML, can you change all of them?

@haircommander
Copy link
Collaborator

@theunrealgeek excellent thank you. a couple more nits but all together looks great to me 👍 😃

@haircommander
Copy link
Collaborator

(also, I agree, test failures look like registry issues. I've tried retriggering them)

@rhatdan
Copy link
Member

rhatdan commented Jun 2, 2020

@theunrealgeek Any progress?

@mheon
Copy link
Member

mheon commented Jun 2, 2020

Tests are fixed on master, FYI - a rebase should pick up the fix

Signed-off-by: Aditya Kamath <theunrealgeek@gmail.com>
Signed-off-by: Aditya Kamath <theunrealgeek@gmail.com>
Signed-off-by: Aditya Kamath <theunrealgeek@gmail.com>
Signed-off-by: Aditya Kamath <theunrealgeek@gmail.com>
Signed-off-by: Aditya Kamath <theunrealgeek@gmail.com>
Signed-off-by: Aditya Kamath <theunrealgeek@gmail.com>
@theunrealgeek
Copy link
Contributor Author

@rhatdan Sorry about the delay, got involved in a prod incident on my day job.

@haircommander I've addressed your comments. Thank you for your review :)

@rhatdan
Copy link
Member

rhatdan commented Jun 3, 2020

@theunrealgeek No problem, thanks for the contribution.
@haircommander @umohnani8 @baude @mrunalp PTAL

@@ -382,7 +445,10 @@ func kubeContainerToCreateConfig(ctx context.Context, containerYAML v1.Container

setupSecurityContext(&securityConfig, &userConfig, containerYAML)

securityConfig.SeccompProfilePath = seccompPaths.findForContainer(containerConfig.Name)
// Since we prefix the container name with pod name to work-around the uniqueness requirement,
// seccom stuff should reference the actual container name from the YAML
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: s/seccom stuff/the seccomp profile

Copy link
Contributor Author

@theunrealgeek theunrealgeek Jun 3, 2020

Choose a reason for hiding this comment

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

Done 👍 @haircommander

Signed-off-by: Aditya Kamath <theunrealgeek@gmail.com>
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Just two non-blocking nits: other than that LGTM

pkg/domain/entities/play.go Show resolved Hide resolved
pkg/domain/entities/play.go Outdated Show resolved Hide resolved
Signed-off-by: Aditya Kamath <theunrealgeek@gmail.com>
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!
@haircommander PTAL

@rhatdan
Copy link
Member

rhatdan commented Jun 5, 2020

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan, theunrealgeek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 5, 2020
@haircommander
Copy link
Collaborator

LGTM 😃


switch len(pod.Containers) {
case 0:
return nil
Copy link
Member

Choose a reason for hiding this comment

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

Should this be a continue so we print all pods in the case that there are more than 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mheon Good catch, copy paste error on my part from the previous version. I've fixed it, thanks

@mheon
Copy link
Member

mheon commented Jun 5, 2020

One last nit, otherwise LGTM. Clear to merge once fixed.

Signed-off-by: Aditya Kamath <theunrealgeek@gmail.com>
@rhatdan
Copy link
Member

rhatdan commented Jun 5, 2020

/lgtm
/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 5, 2020
@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 5, 2020
@rhatdan
Copy link
Member

rhatdan commented Jun 11, 2020

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 11, 2020
@openshift-merge-robot openshift-merge-robot merged commit b62e50f into containers:master Jun 11, 2020
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. ok-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants