mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #15044 from nikhiljindal/deploymentController
Enabling deployments on kubernernetes-upgrade-gce test suite
This commit is contained in:
commit
f4cb23975b
@ -599,6 +599,7 @@ case ${JOB_NAME} in
|
||||
: ${E2E_UP:="true"}
|
||||
: ${E2E_TEST:="false"}
|
||||
: ${E2E_DOWN:="false"}
|
||||
: ${ENABLE_DEPLOYMENTS:=true}
|
||||
NUM_MINIONS=3
|
||||
;;
|
||||
|
||||
|
@ -95,7 +95,12 @@ func testRollingUpdateDeployment(f *Framework) {
|
||||
ns := f.Namespace.Name
|
||||
c := f.Client
|
||||
// Create nginx pods.
|
||||
podLabels := map[string]string{"name": "sample-pod"}
|
||||
deploymentPodLabels := map[string]string{"name": "sample-pod"}
|
||||
rcPodLabels := map[string]string{
|
||||
"name": "sample-pod",
|
||||
"pod": "nginx",
|
||||
}
|
||||
|
||||
rcName := "nginx-controller"
|
||||
_, err := c.ReplicationControllers(ns).Create(&api.ReplicationController{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
@ -103,10 +108,10 @@ func testRollingUpdateDeployment(f *Framework) {
|
||||
},
|
||||
Spec: api.ReplicationControllerSpec{
|
||||
Replicas: 3,
|
||||
Selector: podLabels,
|
||||
Selector: rcPodLabels,
|
||||
Template: &api.PodTemplateSpec{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: podLabels,
|
||||
Labels: rcPodLabels,
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
@ -140,11 +145,11 @@ func testRollingUpdateDeployment(f *Framework) {
|
||||
},
|
||||
Spec: experimental.DeploymentSpec{
|
||||
Replicas: 3,
|
||||
Selector: podLabels,
|
||||
Selector: deploymentPodLabels,
|
||||
UniqueLabelKey: "deployment.kubernetes.io/podTemplateHash",
|
||||
Template: &api.PodTemplateSpec{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: podLabels,
|
||||
Labels: deploymentPodLabels,
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
@ -164,14 +169,19 @@ func testRollingUpdateDeployment(f *Framework) {
|
||||
Expect(c.Deployments(ns).Delete(deploymentName, nil)).NotTo(HaveOccurred())
|
||||
}()
|
||||
|
||||
waitForDeploymentStatus(c, ns, deploymentName, 3, 2, 4)
|
||||
err = waitForDeploymentStatus(c, ns, deploymentName, 3, 2, 4)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
func testRollingUpdateDeploymentEvents(f *Framework) {
|
||||
ns := f.Namespace.Name
|
||||
c := f.Client
|
||||
// Create nginx pods.
|
||||
podLabels := map[string]string{"name": "sample-pod"}
|
||||
deploymentPodLabels := map[string]string{"name": "sample-pod"}
|
||||
rcPodLabels := map[string]string{
|
||||
"name": "sample-pod",
|
||||
"pod": "nginx",
|
||||
}
|
||||
rcName := "nginx-controller"
|
||||
_, err := c.ReplicationControllers(ns).Create(&api.ReplicationController{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
@ -179,10 +189,10 @@ func testRollingUpdateDeploymentEvents(f *Framework) {
|
||||
},
|
||||
Spec: api.ReplicationControllerSpec{
|
||||
Replicas: 1,
|
||||
Selector: podLabels,
|
||||
Selector: rcPodLabels,
|
||||
Template: &api.PodTemplateSpec{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: podLabels,
|
||||
Labels: rcPodLabels,
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
@ -216,11 +226,11 @@ func testRollingUpdateDeploymentEvents(f *Framework) {
|
||||
},
|
||||
Spec: experimental.DeploymentSpec{
|
||||
Replicas: 1,
|
||||
Selector: podLabels,
|
||||
Selector: deploymentPodLabels,
|
||||
UniqueLabelKey: "deployment.kubernetes.io/podTemplateHash",
|
||||
Template: &api.PodTemplateSpec{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: podLabels,
|
||||
Labels: deploymentPodLabels,
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
@ -240,7 +250,8 @@ func testRollingUpdateDeploymentEvents(f *Framework) {
|
||||
Expect(c.Deployments(ns).Delete(deploymentName, nil)).NotTo(HaveOccurred())
|
||||
}()
|
||||
|
||||
waitForDeploymentStatus(c, ns, deploymentName, 1, 0, 2)
|
||||
err = waitForDeploymentStatus(c, ns, deploymentName, 1, 0, 2)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
// Verify that the pods were scaled up and down as expected. We use events to verify that.
|
||||
deployment, err := c.Deployments(ns).Get(deploymentName)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -1580,7 +1580,7 @@ func waitForRCPodsGone(c *client.Client, rc *api.ReplicationController) error {
|
||||
// Waits for the deployment to reach desired state.
|
||||
// Returns an error if minAvailable or maxCreated is broken at any times.
|
||||
func waitForDeploymentStatus(c *client.Client, ns, deploymentName string, desiredUpdatedReplicas, minAvailable, maxCreated int) error {
|
||||
return wait.Poll(poll, 2*time.Minute, func() (bool, error) {
|
||||
return wait.Poll(poll, 5*time.Minute, func() (bool, error) {
|
||||
|
||||
deployment, err := c.Deployments(ns).Get(deploymentName)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user