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

Change kubernetes-dashboard from RC to deployment #2409

Merged
merged 1 commit into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ReplicationController
apiVersion: apps/v1
kind: Deployment
metadata:
name: kubernetes-dashboard
namespace: kube-system
Expand All @@ -24,9 +24,10 @@ metadata:
spec:
replicas: 1
selector:
app: kubernetes-dashboard
version: v1.8.1
addonmanager.kubernetes.io/mode: Reconcile
matchLabels:
app: kubernetes-dashboard
version: v1.8.1
addonmanager.kubernetes.io/mode: Reconcile
template:
metadata:
labels:
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/assets/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ var Addons = map[string]*Addon{
}, true, "addon-manager"),
"dashboard": NewAddon([]*BinDataAsset{
NewBinDataAsset(
"deploy/addons/dashboard/dashboard-rc.yaml",
"deploy/addons/dashboard/dashboard-dp.yaml",
constants.AddonsPath,
"dashboard-rc.yaml",
"dashboard-dp.yaml",
"0640"),
NewBinDataAsset(
"deploy/addons/dashboard/dashboard-svc.yaml",
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const FileScheme = "file"

var LocalkubeCachedImages = []string{
// Dashboard
"k8s.gcr.io/kubernetes-dashboard-amd64:v1.6.3",
"k8s.gcr.io/kubernetes-dashboard-amd64:v1.8.1",

// DNS
"k8s.gcr.io/k8s-dns-kube-dns-amd64:1.14.5",
Expand All @@ -188,7 +188,7 @@ var LocalkubeCachedImages = []string{
func GetKubeadmCachedImages(version string) []string {
return []string{
// Dashboard
"k8s.gcr.io/kubernetes-dashboard-amd64:v1.6.3",
"k8s.gcr.io/kubernetes-dashboard-amd64:v1.8.1",

// Addon Manager
"gcr.io/google-containers/kube-addon-manager:v6.5",
Expand Down
31 changes: 31 additions & 0 deletions pkg/util/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"k8s.io/apimachinery/pkg/watch"
"k8s.io/kubernetes/cmd/kubeadm/app/constants"

appsv1 "k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -168,6 +169,36 @@ func WaitForRCToStabilize(c kubernetes.Interface, ns, name string, timeout time.
return err
}

// WaitForDeploymentToStabilize waits till the Deployment has a matching generation/replica count between spec and status.
func WaitForDeploymentToStabilize(c kubernetes.Interface, ns, name string, timeout time.Duration) error {
options := metav1.ListOptions{FieldSelector: fields.Set{
"metadata.name": name,
"metadata.namespace": ns,
}.AsSelector().String()}
w, err := c.AppsV1().Deployments(ns).Watch(options)
if err != nil {
return err
}
_, err = watch.Until(timeout, w, func(event watch.Event) (bool, error) {
switch event.Type {
case watch.Deleted:
return false, apierrs.NewNotFound(schema.GroupResource{Resource: "deployments"}, "")
}
switch dp := event.Object.(type) {
case *appsv1.Deployment:
if dp.Name == name && dp.Namespace == ns &&
dp.Generation <= dp.Status.ObservedGeneration &&
*(dp.Spec.Replicas) == dp.Status.Replicas {
return true, nil
}
glog.Infof("Waiting for deployment %s to stabilize, generation %v observed generation %v spec.replicas %d status.replicas %d",
name, dp.Generation, dp.Status.ObservedGeneration, *(dp.Spec.Replicas), dp.Status.Replicas)
}
return false, nil
})
return err
}

// WaitForService waits until the service appears (exist == true), or disappears (exist == false)
func WaitForService(c kubernetes.Interface, namespace, name string, exist bool, interval, timeout time.Duration) error {
err := wait.PollImmediate(interval, timeout, func() (bool, error) {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ func WaitForDashboardRunning(t *testing.T) error {
if err != nil {
return errors.Wrap(err, "getting kubernetes client")
}
if err := commonutil.WaitForRCToStabilize(client, "kube-system", "kubernetes-dashboard", time.Minute*10); err != nil {
return errors.Wrap(err, "waiting for dashboard RC to stabilize")
if err := commonutil.WaitForDeploymentToStabilize(client, "kube-system", "kubernetes-dashboard", time.Minute*10); err != nil {
return errors.Wrap(err, "waiting for dashboard deployment to stabilize")
}

if err := commonutil.WaitForService(client, "kube-system", "kubernetes-dashboard", true, time.Millisecond*500, time.Minute*10); err != nil {
Expand Down