Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
test2
  • Loading branch information
rphillips committed Apr 2, 2024
1 parent 41e5ef8 commit 22c5421
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions pkg/monitortests/node/kubeletselinuxlabels/util.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package kubeletselinuxlabels

import (
images "github.com/openshift/origin/test/extended/util/image"
"github.com/MakeNowJust/heredoc"
"github.com/openshift/origin/test/extended/util/image"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -14,14 +15,23 @@ const (
const (
busyScript = `
#!/bin/bash
while true
do
echo "Busy working, cycling through the ones and zeros"
set -eou pipefail
SUB='kubelet_t'
while true; do
kubelet_label=$(ps -Z -C kubelet)
SUB='kubelet_t'
if [[ "$kubelet_label" == "" ]]; then
echo "kubelet not running"
sleep 5
continue
fi
if [[ "$kubelet_label" != *"$SUB"* ]]; then
echo "failing selinux label"
exit 1
fi
echo "found selinux label"
sleep 5
done
`
Expand All @@ -32,8 +42,6 @@ done
// Pod tests if kubelet has the right selinux label
// and fails the pod if it doesn't.
func selinuxPodSpec(name, namespace, nodeName string) *corev1.Pod {
isTrue := true
isZero := int64(0)
return &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand All @@ -43,27 +51,23 @@ func selinuxPodSpec(name, namespace, nodeName string) *corev1.Pod {
RestartPolicy: corev1.RestartPolicyNever,
PriorityClassName: "system-cluster-critical",
NodeName: nodeName,
HostPID: true,
Containers: []corev1.Container{
{

Image: images.LimitedShellImage(),
Image: image.LimitedShellImage(),
ImagePullPolicy: corev1.PullIfNotPresent,
Name: name,
Command: []string{
"/bin/bash",
"bash",
"-c",
busyScript,
heredoc.Doc(busyScript),
},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("10m"),
corev1.ResourceMemory: resource.MustParse("50Mi"),
},
},
SecurityContext: &corev1.SecurityContext{
Privileged: &isTrue,
RunAsUser: &isZero,
},
},
},
},
Expand Down

0 comments on commit 22c5421

Please sign in to comment.