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

Promote init containers to GA #38382

Merged
merged 3 commits into from
Feb 3, 2017

Conversation

hodovska
Copy link

@hodovska hodovska commented Dec 8, 2016

This is proposed for 1.6
PR moves beta proved concept for init containers to stable. Specification of init containers can be now stated under initContainers field in PodSpec/PodTemplateSpec. Specifying init-containers in annotation is still possible, but will be removed in future version.

Init containers have graduated to GA and now appear as a field.  The beta annotation value will still be respected and overrides the field value.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 8, 2016
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. release-note-label-needed labels Dec 8, 2016
return err
}

if old := out.Annotations; old != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Code that uses init containers (which is mostly using versioned clients now) still needs to respect the beta annotation. So this code needs to move into a function that you can use to, if the annotation is set, override the value that is provided with the object. For backwards compatibility with APIs "beta" annotations take precedence over fields.

Copy link
Author

Choose a reason for hiding this comment

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

Is it true that this file contains only functions in format

func Convert_v1_Field_To_api_Field(in *Field, out *api.Field, s conversion.Scope) error 

where type of Field is defined in types.go?

Mentioned function would need access to Annotations and InitContainers field, that means pointer to Pod. Is there a file where we put this kind of functions? Is it more acceptable not to modify conversions for init containers promotion?

Copy link
Author

Choose a reason for hiding this comment

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

@jwforres pointing out to this question

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 9, 2016
@derekwaynecarr
Copy link
Member

@hodovska -- can you split the generated code into a separate commit to allow for easier review?

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 13, 2016
@hodovska
Copy link
Author

Does also proposal file have to be updated? (https://github.com/kubernetes/kubernetes/blob/master/docs/proposals/container-init.md) Speaking of statements such as "While pod containers are in alpha state..."

@@ -1274,22 +1274,24 @@ var map_PodSpec = map[string]string{
"imagePullSecrets": "ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info: http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod",
"hostname": "Specifies the hostname of the Pod If not specified, the pod's hostname will be set to a system-defined value.",
"subdomain": "If specified, the fully qualified Pod hostname will be \"<hostname>.<subdomain>.<pod namespace>.svc.<cluster domain>\". If not specified, the pod will not have a domainname at all.",
"initContainers": "List of initialization containers belonging to the pod. Init containers are executed in order prior to containers being started. If any init container fails, the pod is considered to have failed and is handled according to its restartPolicy. The name for an init container or normal container must be unique among all containers. Init containers may not have Lifecycle actions, Readiness probes, or Liveness probes. The resourceRequirements of an init container are taken into account during scheduling by finding the highest request/limit for each resource type, and then using the max of of that value or the sum of the normal containers. Limits are applied to init containers in a similar fashion. Init containers cannot currently be added or removed. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/containers",
Copy link
Contributor

Choose a reason for hiding this comment

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

noticed a typo, two of's "the max of of that"

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 13, 2016
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 14, 2016
@derekwaynecarr
Copy link
Member

The proposals have moved to kubernetes/community repo, so an update will be needed there.

A few additional asks for this PR:

  1. i think we need to error if there is a conflict between the value stored as an annotation versus the non-annotated form. maybe @smarterclayton has some thoughts there, but i think we should do something to handle conflict resolution in this pr.
  2. the existing e2e tests all verify the function works when its set via annotation. i think we need to have test coverage that verifies the function works even if the annotation is not set. see: https://github.com/kubernetes/kubernetes/blob/master/test/e2e/common/init_container.go for the tests in question.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 16, 2016
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 2, 2017
@hodovska
Copy link
Author

hodovska commented Jan 2, 2017

Conversion:

  • v1 => internal api
    possible ways to specify initContainers are: metadata.annotations(PodInitContainerStatusesBetaAnnotationKey, PodInitContainerStatusesAnnotationKey) or field spec.initContainers, but when both are filled error is shown and conversion stops. After conversion metadata.annotations values with keys mentioned above are deleted

  • internal api => v1
    value in spec.initContainers is moved to metadata.annotation fields. It has to be removed from spec.initContainers, so following conversion to internal api will be with no errors. (- this causes huge issues, conversion shouldn't be modified this way)

We might use different, where conversion stays as is and possible conflict (annotations vs. spec.initContainers) is resolved in validation. For this I will need more information of how to run v1 validation (before conversion to internal api).

@smarterclayton
Copy link
Contributor

smarterclayton commented Jan 2, 2017 via email

pkg/api/types.go Outdated
@@ -1911,6 +1909,8 @@ type PodSpec struct {
// If not specified, the pod will be dispatched by default scheduler.
// +optional
SchedulerName string
// List of initialization containers belonging to the pod.
InitContainers []Container
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this moved to the bottom?

Copy link
Author

Choose a reason for hiding this comment

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

@smarterclayton new ID of json field has to be assigned. I found this approach least impacting, since ID's have to be sorted - I didn't intend to influence other fields.

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't sort based on id, and ids aren't added by sort. Order of fields is supposed to be human / use first, machine last. Move these back.

// Init containers are in alpha state and may change without notice.
// Cannot be updated.
// More info: http://kubernetes.io/docs/user-guide/containers
InitContainers []Container `json:"-" patchStrategy:"merge" patchMergeKey:"name"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave this where it is.

// startTime set.
// Init containers are in alpha state and may change without notice.
// More info: http://kubernetes.io/docs/user-guide/pod-states#container-statuses
InitContainerStatuses []ContainerStatus `json:"-"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave this where it is.

@smarterclayton
Copy link
Contributor

A couple of comments and rebase and regenerate, and yes, LGTM

/approve

@k8s-github-robot k8s-github-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 1, 2017
@smarterclayton
Copy link
Contributor

smarterclayton commented Feb 1, 2017

Please add the release note to the PR description:

```release-note
Init containers have graduated to GA and now appear as a field.  The beta annotation value will still be respected and overrides the field value.
```

@k8s-github-robot k8s-github-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Feb 2, 2017
@k8s-github-robot k8s-github-robot removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 3, 2017
@smarterclayton
Copy link
Contributor

/approve

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

The following people have approved this PR: hodovska, smarterclayton

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 3, 2017
@smarterclayton
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 3, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 40864, 40666, 38382, 40874)

@k8s-github-robot k8s-github-robot merged commit 8b795e2 into kubernetes:master Feb 3, 2017
k8s-github-robot pushed a commit that referenced this pull request May 6, 2017
Automatic merge from submit-queue

Put initContainers to PodSpec for some statefulset examples.

**What this PR does / why we need it**:
Fixed #45405

The `init container` is [graduated to GA](#38382) , so some test YAML templates needs to be updated to not use `annotations`.

The following are the two places that needs update:
1. [cockroachdb](https://github.com/kubernetes/kubernetes/blob/master/examples/cockroachdb/cockroachdb-statefulset.yaml)
2. [e2e statefulset test](https://github.com/kubernetes/kubernetes/tree/master/test/e2e/testing-manifests/statefulset)

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.