89 lines
2.0 KiB
Go
89 lines
2.0 KiB
Go
/*
|
|
Copyright 2018 the Heptio Ark contributors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package install
|
|
|
|
import (
|
|
corev1 "k8s.io/api/core/v1"
|
|
rbacv1beta1 "k8s.io/api/rbac/v1beta1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
)
|
|
|
|
func labels() map[string]string {
|
|
return map[string]string{
|
|
"component": "velero",
|
|
}
|
|
}
|
|
|
|
func podAnnotations() map[string]string {
|
|
return map[string]string{
|
|
"prometheus.io/scrape": "true",
|
|
"prometheus.io/port": "8085",
|
|
"prometheus.io/path": "/metrics",
|
|
}
|
|
}
|
|
|
|
func containerPorts() []corev1.ContainerPort {
|
|
return []corev1.ContainerPort{
|
|
{
|
|
Name: "metrics",
|
|
ContainerPort: 8085,
|
|
},
|
|
}
|
|
}
|
|
|
|
func objectMeta(namespace, name string) metav1.ObjectMeta {
|
|
return metav1.ObjectMeta{
|
|
Name: name,
|
|
Namespace: namespace,
|
|
Labels: labels(),
|
|
}
|
|
}
|
|
|
|
func ServiceAccount(namespace string) *corev1.ServiceAccount {
|
|
return &corev1.ServiceAccount{
|
|
ObjectMeta: objectMeta(namespace, "velero"),
|
|
}
|
|
}
|
|
|
|
func ClusterRoleBinding(namespace string) *rbacv1beta1.ClusterRoleBinding {
|
|
return &rbacv1beta1.ClusterRoleBinding{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: "velero",
|
|
},
|
|
Subjects: []rbacv1beta1.Subject{
|
|
{
|
|
Kind: "ServiceAccount",
|
|
Namespace: namespace,
|
|
Name: "velero",
|
|
},
|
|
},
|
|
RoleRef: rbacv1beta1.RoleRef{
|
|
Kind: "ClusterRole",
|
|
Name: "cluster-admin",
|
|
APIGroup: "rbac.authorization.k8s.io",
|
|
},
|
|
}
|
|
}
|
|
|
|
func Namespace(namespace string) *corev1.Namespace {
|
|
return &corev1.Namespace{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: namespace,
|
|
},
|
|
}
|
|
}
|