-
Notifications
You must be signed in to change notification settings - Fork 228
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 the network metrics daemon as part of the CNO. #552
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: metrics-daemon-sa | ||
namespace: openshift-multus | ||
--- | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: metrics-daemon-role | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods"] | ||
verbs: ["get", "watch", "list"] | ||
- apiGroups: ["k8s.cni.cncf.io"] | ||
resources: ["network-attachment-definitions"] | ||
verbs: ["get", "watch", "list"] | ||
- apiGroups: ["authentication.k8s.io"] | ||
resources: ["tokenreviews"] | ||
verbs: ["create"] | ||
- apiGroups: ["authorization.k8s.io"] | ||
resources: ["subjectaccessreviews"] | ||
verbs: ["create"] | ||
--- | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: metrics-daemon-sa-rolebinding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: metrics-daemon-sa | ||
apiGroup: "" | ||
namespace: openshift-multus | ||
roleRef: | ||
kind: ClusterRole | ||
name: metrics-daemon-role | ||
apiGroup: rbac.authorization.k8s.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
kind: DaemonSet | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: network-metrics-daemon | ||
namespace: openshift-multus | ||
annotations: | ||
kubernetes.io/description: | | ||
This daemonset launches the network metrics daemon on each node | ||
release.openshift.io/version: "{{.ReleaseVersion}}" | ||
networkoperator.openshift.io/non-critical: "" | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: network-metrics-daemon | ||
updateStrategy: | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
labels: | ||
app: network-metrics-daemon | ||
component: network | ||
type: infra | ||
openshift.io/component: network | ||
spec: | ||
nodeSelector: | ||
node-role.kubernetes.io/worker: "" | ||
tolerations: | ||
- operator: Exists | ||
containers: | ||
- name: network-metrics-daemon | ||
image: {{.NetworkMetricsImage}} | ||
command: | ||
- /usr/bin/network-metrics | ||
args: ["--node-name", "$(NODE_NAME)"] | ||
resources: | ||
requests: | ||
cpu: 10m | ||
memory: 100Mi | ||
imagePullPolicy: IfNotPresent | ||
env: | ||
- name: NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
- name: kube-rbac-proxy | ||
image: {{.KubeRBACProxyImage}} | ||
args: | ||
- --logtostderr | ||
- --secure-listen-address=:8443 | ||
- --tls-cipher-suites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 | ||
- --upstream=http://127.0.0.1:9091/ | ||
- --tls-private-key-file=/etc/metrics/tls.key | ||
- --tls-cert-file=/etc/metrics/tls.crt | ||
ports: | ||
- containerPort: 8443 | ||
name: https | ||
resources: | ||
requests: | ||
cpu: 10m | ||
memory: 20Mi | ||
terminationMessagePolicy: FallbackToLogsOnError | ||
volumeMounts: | ||
- name: metrics-certs | ||
mountPath: /etc/metrics | ||
readOnly: True | ||
volumes: | ||
- name: metrics-certs | ||
secret: | ||
secretName: metrics-daemon-secret | ||
serviceAccountName: metrics-daemon-sa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: ServiceMonitor | ||
metadata: | ||
labels: | ||
name: monitor-network | ||
annotations: | ||
networkoperator.openshift.io/ignore-errors: "" | ||
name: monitor-network | ||
namespace: openshift-multus | ||
spec: | ||
endpoints: | ||
- interval: 10s | ||
port: metrics | ||
honorLabels: true | ||
bearerTokenFile: "/var/run/secrets/kubernetes.io/serviceaccount/token" | ||
scheme: "https" | ||
tlsConfig: | ||
caFile: "/etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt" | ||
serverName: "network-metrics-service.openshift-multus.svc" | ||
selector: | ||
matchLabels: | ||
service: network-metrics-service | ||
namespaceSelector: | ||
matchNames: | ||
- openshift-multus | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
prometheus.io/scrape: "true" | ||
service.alpha.openshift.io/serving-cert-secret-name: metrics-daemon-secret | ||
labels: | ||
service: network-metrics-service | ||
name: network-metrics-service | ||
namespace: openshift-multus | ||
spec: | ||
selector: | ||
app: network-metrics-daemon | ||
clusterIP: None | ||
ports: | ||
- name: metrics | ||
port: 8443 | ||
targetPort: https | ||
type: ClusterIP | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: prometheus-k8s | ||
namespace: openshift-multus | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- services | ||
- endpoints | ||
- pods | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: prometheus-k8s | ||
namespace: openshift-multus | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: prometheus-k8s | ||
subjects: | ||
- kind: ServiceAccount | ||
name: prometheus-k8s | ||
namespace: openshift-monitoring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package network | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/gomega" | ||
operv1 "github.com/openshift/api/operator/v1" | ||
"github.com/openshift/cluster-network-operator/pkg/apply" | ||
) | ||
|
||
var NetworkMetricsDaemonConfig = operv1.Network{ | ||
Spec: operv1.NetworkSpec{ | ||
ServiceNetwork: []string{"172.30.0.0/16"}, | ||
ClusterNetwork: []operv1.ClusterNetworkEntry{ | ||
{ | ||
CIDR: "10.128.0.0/15", | ||
HostPrefix: 23, | ||
}, | ||
}, | ||
DefaultNetwork: operv1.DefaultNetworkDefinition{ | ||
Type: operv1.NetworkTypeOpenShiftSDN, | ||
OpenShiftSDNConfig: &operv1.OpenShiftSDNConfig{ | ||
Mode: operv1.SDNModeNetworkPolicy, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
// TestRenderNetworkMetricsDaemon has some simple rendering tests | ||
func TestRenderNetworkMetricsDaemon(t *testing.T) { | ||
g := NewGomegaWithT(t) | ||
|
||
crd := NetworkMetricsDaemonConfig.DeepCopy() | ||
config := &crd.Spec | ||
disabled := true | ||
config.DisableMultiNetwork = &disabled | ||
FillDefaults(config, nil) | ||
|
||
// disable MultusAdmissionController | ||
objs, err := RenderMultus(config, manifestDir) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
g.Expect(objs).NotTo(ContainElement(HaveKubernetesID("DaemonSet", "openshift-multus", "network-metrics-daemon"))) | ||
|
||
// enable MultusAdmissionController | ||
enabled := false | ||
config.DisableMultiNetwork = &enabled | ||
objs, err = RenderMultus(config, manifestDir) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
g.Expect(objs).To(ContainElement(HaveKubernetesID("DaemonSet", "openshift-multus", "network-metrics-daemon"))) | ||
|
||
// Check rendered object | ||
|
||
g.Expect(len(objs)).To(Equal(18)) | ||
g.Expect(objs).To(ContainElement(HaveKubernetesID("DaemonSet", "openshift-multus", "network-metrics-daemon"))) | ||
g.Expect(objs).To(ContainElement(HaveKubernetesID("Service", "openshift-multus", "network-metrics-service"))) | ||
g.Expect(objs).To(ContainElement(HaveKubernetesID("ClusterRole", "", "metrics-daemon-role"))) | ||
g.Expect(objs).To(ContainElement(HaveKubernetesID("ClusterRoleBinding", "", "metrics-daemon-sa-rolebinding"))) | ||
g.Expect(objs).To(ContainElement(HaveKubernetesID("ServiceMonitor", "openshift-multus", "monitor-network"))) | ||
g.Expect(objs).To(ContainElement(HaveKubernetesID("Role", "openshift-multus", "prometheus-k8s"))) | ||
g.Expect(objs).To(ContainElement(HaveKubernetesID("RoleBinding", "openshift-multus", "prometheus-k8s"))) | ||
|
||
// Make sure every obj is reasonable: | ||
// - it is supported | ||
// - it reconciles to itself (steady state) | ||
for _, obj := range objs { | ||
g.Expect(apply.IsObjectSupported(obj)).NotTo(HaveOccurred()) | ||
cur := obj.DeepCopy() | ||
upd := obj.DeepCopy() | ||
|
||
err = apply.MergeObjectForUpdate(cur, upd) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
|
||
tweakMetaForCompare(cur) | ||
g.Expect(cur).To(Equal(upd)) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nit: If this is part of Multus, then shouldn't it just be in
bindata/network/multus
? It can't be installed separately, right?(It's in the
openshift-multus
namespace, so the answer to that question is presently no)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't, as much as
multus-admission-controller
can't. I tried to stick to the same convention, see https://github.com/openshift/cluster-network-operator/tree/master/bindata/network/multus-admission-controllerIt also look more clear what manifests belong to which component.
But if you prefer I can put the manifests under multus.