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

Fix mirror pods #2885

Merged
merged 2 commits into from
Jan 21, 2020
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
2 changes: 1 addition & 1 deletion cluster/node-pools/master-default/userdata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ write_files:
- mountPath: /etc/kubernetes/ssl
name: ssl-certs-kubernetes
readOnly: true
- image: registry.opensource.zalan.do/teapot/k8s-authnz-webhook:v0.7.4
- image: registry.opensource.zalan.do/teapot/k8s-authnz-webhook:v0.7.5
name: webhook
ports:
- containerPort: 8081
Expand Down
52 changes: 52 additions & 0 deletions test/e2e/infra.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package e2e

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
kubeapi "k8s.io/kubernetes/pkg/apis/core"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework"
)

var _ = framework.KubeDescribe("Infrastructure tests", func() {
f := framework.NewDefaultFramework("zalando-kube-infra")
var cs kubernetes.Interface

BeforeEach(func() {
cs = f.ClientSet
})

It("Mirror pods should be created for the main Kubernetes components [Zalando]", func() {
for _, application := range []string{"kube-apiserver", "kube-controller-manager", "kube-scheduler"} {
pods, err := podsForApplication(cs, application)
Expect(err).NotTo(HaveOccurred())
Expect(filterMirrorPods(pods)).NotTo(BeEmpty())
}
})

})

func podsForApplication(cs kubernetes.Interface, application string) ([]v1.Pod, error) {
matchingPods, err := cs.CoreV1().Pods(kubeapi.NamespaceSystem).List(metav1.ListOptions{
LabelSelector: metav1.FormatLabelSelector(&metav1.LabelSelector{
MatchLabels: map[string]string{"application": application},
}),
})
if err != nil {
return nil, err
}
return matchingPods.Items, nil
}

func filterMirrorPods(pods []v1.Pod) []v1.Pod {
var result []v1.Pod
for _, pod := range pods {
if mirror := pod.Annotations["kubernetes.io/config.mirror"]; mirror != "" {
result = append(result, pod)
}
}
return result
}