forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a single entrypoint for the prometheus-operator
Make sure that all kubevirt components which provide logs are selected by the "kubevirt-prometheus-metrics" endpoint. The openshift-operator can look up the registered endpoints behind it and create a scrape config.
- Loading branch information
Showing
9 changed files
with
141 additions
and
44 deletions.
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
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,16 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: kubevirt-prometheus-metrics | ||
namespace: {{.Namespace}} | ||
labels: | ||
prometheus.kubevirt.io: "" | ||
kubevirt.io: "" | ||
spec: | ||
ports: | ||
- name: metrics | ||
port: 443 | ||
targetPort: metrics | ||
protocol: TCP | ||
selector: | ||
prometheus.kubevirt.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
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,47 @@ | ||
package certificates | ||
|
||
import ( | ||
"io/ioutil" | ||
"strings" | ||
|
||
"k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/util/cert" | ||
"k8s.io/client-go/util/cert/triple" | ||
"k8s.io/client-go/util/certificate" | ||
) | ||
|
||
func GenerateSelfSignedCert(name string, namespace string) (certificate.FileStore, error) { | ||
caKeyPair, _ := triple.NewCA("kubevirt.io") | ||
keyPair, _ := triple.NewServerKeyPair( | ||
caKeyPair, | ||
name+"."+namespace+".pod.cluster.local", | ||
name, | ||
namespace, | ||
"cluster.local", | ||
nil, | ||
nil, | ||
) | ||
|
||
certsDirectory, err := ioutil.TempDir("", "certsdir") | ||
if err != nil { | ||
return nil, err | ||
} | ||
store, err := certificate.NewFileStore(name, certsDirectory, certsDirectory, "", "") | ||
if err != nil { | ||
return nil, err | ||
} | ||
_, err = store.Update(cert.EncodeCertPEM(keyPair.Cert), cert.EncodePrivateKeyPEM(keyPair.Key)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return store, nil | ||
} | ||
|
||
func GetNamespace() string { | ||
if data, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil { | ||
if ns := strings.TrimSpace(string(data)); len(ns) > 0 { | ||
return ns | ||
} | ||
} | ||
return v1.NamespaceSystem | ||
} |
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
Oops, something went wrong.