Преглед на файлове

deploy PR to sandbox (#11)

* deploy PR to sandbox

* add rbac

* +

* +

* + rbac

* allow namespaces
pull/12/head
Vladimir Smagin преди 6 месеца
родител
ревизия
19ecb5a7d9
No account linked to committer's email address
променени са 6 файла, в които са добавени 53 реда и са изтрити 11 реда
  1. +45
    -1
      Jenkinsfile
  2. +8
    -6
      cmd/manager/main.go
  3. +0
    -1
      deploy/deploy-operator-debug/clusterrole.yaml
  4. +0
    -1
      deploy/deploy-operator-debug/role.yaml
  5. +0
    -1
      deploy/deploy-operator-default/clusterrole.yaml
  6. +0
    -1
      deploy/deploy-operator-default/role.yaml

+ 45
- 1
Jenkinsfile Целия файл

@@ -16,6 +16,7 @@ node {
}
}

// check branch and select cluster to deploy
if (branch == 'master') {
stage ('Wait for confirmation of build promotion') {
input message: 'Is this build ready for production?', submitter: 'tekliner'
@@ -52,10 +53,53 @@ spec:
- name: OPERATOR_NAME
value: "rabbitmq-operator"
- name: WATCH_NAMESPACE
value: "messaging"
value: ""
"""
archiveArtifacts: 'operator.yaml'
sh "kubectl apply -f operator.yaml -n messaging"
}
} else {
// deploy PR to sandbox
stage ('Deploy to sandbox') {
writeFile file: 'operator.yaml', text: """
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: rabbitmq-operator
spec:
replicas: 1
selector:
matchLabels:
app: rabbitmq-operator
template:
metadata:
labels:
app: rabbitmq-operator
spec:
serviceAccountName: rabbitmq-operator
containers:
- name: rabbitmq-operator
image: 716309063777.dkr.ecr.us-east-1.amazonaws.com/rabbitmq-operator:${branch}-${build}
command:
- rabbitmq-operator
imagePullPolicy: Always
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: "rabbitmq-operator"
- name: WATCH_NAMESPACE
value: "rabbitmq-operator-${branch}"
"""
archiveArtifacts: 'operator.yaml'
// create separated namespace and deploy operator into it
sh "HOME=/root;KUBECONFIG=/root/.kube/sandbox.config kubectl create ns rabbitmq-operator-${branch} || true"
sh "HOME=/root;KUBECONFIG=/root/.kube/sandbox.config kubectl apply -f deploy/deploy-operator-default/service_account.yaml -n rabbitmq-operator-${branch} || true"
sh "HOME=/root;KUBECONFIG=/root/.kube/sandbox.config kubectl apply -f deploy/deploy-operator-default/role_binding.yaml -n rabbitmq-operator-${branch} || true"
sh "HOME=/root;KUBECONFIG=/root/.kube/sandbox.config kubectl apply -f operator.yaml -n rabbitmq-operator-${branch} || true"
}
}
}

+ 8
- 6
cmd/manager/main.go Целия файл

@@ -7,13 +7,14 @@ import (
"os"
"runtime"

prometheusApis "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
"github.com/operator-framework/operator-sdk/pkg/k8sutil"
"github.com/operator-framework/operator-sdk/pkg/leader"
"github.com/operator-framework/operator-sdk/pkg/log/zap"
"github.com/operator-framework/operator-sdk/pkg/metrics"
sdkVersion "github.com/operator-framework/operator-sdk/version"
"github.com/spf13/pflag"
"github.com/tekliner/rabbitmq-operator/pkg/apis"
prometheusApis "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
"github.com/tekliner/rabbitmq-operator/pkg/controller"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"sigs.k8s.io/controller-runtime/pkg/client/config"
@@ -59,11 +60,11 @@ func main() {
printVersion()

// do not watch namespace
// namespace, err := k8sutil.GetWatchNamespace()
// if err != nil {
// log.Error(err, "Failed to get watch namespace")
// os.Exit(1)
// }
namespace, err := k8sutil.GetWatchNamespace()
if err != nil {
log.Error(err, "Failed to get watch namespace")
os.Exit(1)
}

// Get a config to talk to the apiserver
cfg, err := config.GetConfig()
@@ -83,6 +84,7 @@ func main() {

// Create a new Cmd to provide shared dependencies and start components
mgr, err := manager.New(cfg, manager.Options{
Namespace: namespace,
MetricsBindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
})
if err != nil {

+ 0
- 1
deploy/deploy-operator-debug/clusterrole.yaml Целия файл

@@ -1,7 +1,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: rabbitmq-operator
rules:
- apiGroups:

+ 0
- 1
deploy/deploy-operator-debug/role.yaml Целия файл

@@ -1,7 +1,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
creationTimestamp: null
name: rabbitmq-operator
rules:
- apiGroups:

+ 0
- 1
deploy/deploy-operator-default/clusterrole.yaml Целия файл

@@ -1,7 +1,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: rabbitmq-operator
rules:
- apiGroups:

+ 0
- 1
deploy/deploy-operator-default/role.yaml Целия файл

@@ -1,7 +1,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
creationTimestamp: null
name: rabbitmq-operator
rules:
- apiGroups:

Loading…
Отказ
Запис