Change kubernetes-dashboard from RC to Deployment
parent
b1091853cc
commit
08f4677511
|
@ -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
|
||||
|
@ -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:
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue