-
Notifications
You must be signed in to change notification settings - Fork 4
/
k8s.go
46 lines (40 loc) · 879 Bytes
/
k8s.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package fake
import (
"fmt"
"math/rand"
)
// K8sLabels generates a random set of Kubernetes labels.
func K8sLabels() []string {
var l []string
for _, name := range labels {
if rand.Intn(2) == 0 { // 50% chance of picking up this label
l = append(l, name+"="+App())
}
}
return l
}
// K8sNamespace generates a random Kubernetes namespace name.
func K8sNamespace() string {
if rand.Intn(2) == 0 {
return namespaces[rand.Intn(len(namespaces))]
}
return fmt.Sprintf("%s-%s", App(), DeploymentTier())
}
// K8sNodeName generates a random Kubernetes node name.
func K8sNodeName() string {
return fmt.Sprintf(
"%s-%s",
Adjective(),
Noun(),
)
}
// K8sPodName generates a random Kubernetes pod name.
func K8sPodName() string {
return fmt.Sprintf(
"%s-%s",
App(),
AlphaNum(5),
)
}