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

Deploy a service for the Node Problem Detector component #9483

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/component/nodemanagement/nodeproblemdetector/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ func generateClusterFilters() []*fluentbitv1alpha2.ClusterFilter {
return []*fluentbitv1alpha2.ClusterFilter{
{
ObjectMeta: metav1.ObjectMeta{
Name: deploymentName,
Name: daemonSetName,
Labels: map[string]string{v1beta1constants.LabelKeyCustomLoggingResource: v1beta1constants.LabelValueCustomLoggingResource},
},
Spec: fluentbitv1alpha2.FilterSpec{
Match: fmt.Sprintf("kubernetes.*%s*%s*", deploymentName, containerName),
Match: fmt.Sprintf("kubernetes.*%s*%s*", daemonSetName, containerName),
FilterItems: []fluentbitv1alpha2.FilterItem{
{
Parser: &fluentbitv1alpha2filter.Parser{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
rbacv1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
vpaautoscalingv1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -41,7 +42,7 @@ const (
// ManagedResourceName is the name of the ManagedResource containing the resource specifications.
ManagedResourceName = "shoot-core-node-problem-detector"
serviceAccountName = "node-problem-detector"
deploymentName = "node-problem-detector"
serviceName = "node-problem-detector"
containerName = "node-problem-detector"
daemonSetName = "node-problem-detector"
clusterRoleName = "node-problem-detector"
Expand Down Expand Up @@ -308,6 +309,29 @@ func (c *nodeProblemDetector) computeResourcesData() (map[string][]byte, error)
},
}

service = &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: serviceName,
Namespace: metav1.NamespaceSystem,
Labels: map[string]string{
"app.kubernetes.io/instance": "shoot-core",
"app.kubernetes.io/name": labelValue,
v1beta1constants.LabelApp: labelValue,
v1beta1constants.GardenRole: v1beta1constants.GardenRoleSystemComponent,
},
istvanballok marked this conversation as resolved.
Show resolved Hide resolved
},
Spec: corev1.ServiceSpec{
Selector: getLabels(),
Ports: []corev1.ServicePort{
{
Port: int32(daemonSetPrometheusPort),
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt32(daemonSetPrometheusPort),
},
},
},
}

vpa *vpaautoscalingv1.VerticalPodAutoscaler
)

Expand Down Expand Up @@ -355,6 +379,7 @@ func (c *nodeProblemDetector) computeResourcesData() (map[string][]byte, error)
clusterRole,
clusterRoleBinding,
daemonSet,
service,
vpa,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,29 @@ subjects:
name: node-problem-detector
namespace: kube-system
`

serviceYAML = `apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: node-problem-detector
app.kubernetes.io/instance: shoot-core
app.kubernetes.io/name: node-problem-detector
gardener.cloud/role: system-component
name: node-problem-detector
namespace: kube-system
spec:
ports:
- port: 20257
protocol: TCP
targetPort: 20257
selector:
app.kubernetes.io/instance: shoot-core
app.kubernetes.io/name: node-problem-detector
status:
loadBalancer: {}
`
hostPathFileOrCreate = corev1.HostPathFileOrCreate

daemonsetYAMLFor = func(apiserverHost string, vpaEnabled bool) string {
Expand Down Expand Up @@ -310,11 +333,12 @@ status: {}
Expect(string(managedResourceSecret.Data["serviceaccount__kube-system__node-problem-detector.yaml"])).To(Equal(serviceAccountYAML))
Expect(string(managedResourceSecret.Data["clusterrole____node-problem-detector.yaml"])).To(Equal(clusterRoleYAML))
Expect(string(managedResourceSecret.Data["clusterrolebinding____node-problem-detector.yaml"])).To(Equal(clusterRoleBindingYAML))
Expect(string(managedResourceSecret.Data["service__kube-system__node-problem-detector.yaml"])).To(Equal(serviceYAML))
})

Context("w/o apiserver host, w/o vpaEnabled", func() {
It("should successfully deploy all resources", func() {
Expect(managedResourceSecret.Data).To(HaveLen(4))
Expect(managedResourceSecret.Data).To(HaveLen(5))
Expect(string(managedResourceSecret.Data["daemonset__kube-system__node-problem-detector.yaml"])).To(Equal(daemonsetYAMLFor("", false)))
})
})
Expand All @@ -331,7 +355,7 @@ status: {}
})

It("should successfully deploy all resources", func() {
Expect(managedResourceSecret.Data).To(HaveLen(5))
Expect(managedResourceSecret.Data).To(HaveLen(6))
Expect(string(managedResourceSecret.Data["verticalpodautoscaler__kube-system__node-problem-detector.yaml"])).To(Equal(vpaYAML))
Expect(string(managedResourceSecret.Data["daemonset__kube-system__node-problem-detector.yaml"])).To(Equal(daemonsetYAMLFor(apiserverHost, vpaEnabled)))
})
Expand Down