├── .gitignore ├── Dockerfile ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── Makefile ├── README.md ├── cloudbuild.yaml ├── cmd └── manager │ └── main.go ├── config ├── crds │ ├── airflow_v1alpha1_airflowbase.yaml │ └── airflow_v1alpha1_airflowcluster.yaml ├── default │ ├── kustomization.yaml │ ├── manager │ │ └── manager.yaml │ ├── manager_image_patch.yaml │ └── rbac │ │ ├── rbac_role.yaml │ │ └── rbac_role_binding.yaml ├── rbac │ ├── rbac_role.yaml │ └── rbac_role_binding.yaml └── samples │ ├── airflow_v1alpha1_airflowbase.yaml │ └── airflow_v1alpha1_airflowcluster.yaml ├── docs ├── airflow-base.png ├── airflow-cluster.png ├── airflow-multi-node.png ├── airflow-pod.png ├── airflow-region-spread.png ├── airflow-zone-spread.png ├── api.md ├── design.md ├── development.md ├── quickstart.md └── userguide.md ├── hack ├── appcrd.yaml ├── boilerplate.go.txt └── sample │ ├── cloudsql-celery │ ├── base.yaml │ ├── cluster.yaml │ └── sqlproxy-secret.yaml │ ├── cloudsql-k8s │ └── cluster.yaml │ ├── cloudsql-local │ └── cluster.yaml │ ├── mysql-celery-gcs │ └── cluster.yaml │ ├── mysql-celery │ ├── base.yaml │ └── cluster.yaml │ ├── mysql-k8s │ └── cluster.yaml │ ├── mysql-local │ └── cluster.yaml │ ├── postgres-celery-memorystore │ └── cluster.yaml │ ├── postgres-celery-redis │ ├── cluster.yaml │ ├── redis-secret.yaml │ └── redis.yaml │ ├── postgres-celery │ ├── base.yaml │ └── cluster.yaml │ ├── postgres-k8s │ └── cluster.yaml │ └── postgres-local │ └── cluster.yaml ├── pkg ├── apis │ ├── addtoscheme_airflow_v1alpha1.go │ ├── airflow │ │ ├── group.go │ │ └── v1alpha1 │ │ │ ├── airflowbase_types.go │ │ │ ├── airflowbase_types_test.go │ │ │ ├── airflowcluster_types.go │ │ │ ├── airflowcluster_types_test.go │ │ │ ├── doc.go │ │ │ ├── register.go │ │ │ ├── v1alpha1_suite_test.go │ │ │ └── zz_generated.deepcopy.go │ └── apis.go ├── controller │ ├── add_airflowbase.go │ ├── add_airflowcluster.go │ ├── airflowbase │ │ ├── airflowbase_controller.go │ │ ├── airflowbase_controller_suite_test.go │ │ └── airflowbase_controller_test.go │ ├── airflowcluster │ │ ├── airflowcluster_controller.go │ │ ├── airflowcluster_controller_suite_test.go │ │ └── airflowcluster_controller_test.go │ ├── application │ │ ├── application.go │ │ ├── application_suite_test.go │ │ ├── application_test.go │ │ └── doc.go │ ├── common │ │ └── common.go │ └── controller.go └── webhook │ └── webhook.go ├── templates ├── airflow-configmap.yaml ├── base-application.yaml ├── cluster-application.yaml ├── flower-sts.yaml ├── headlesssvc.yaml ├── mysql-sts.yaml ├── nfs-sts.yaml ├── pdb.yaml ├── postgres-sts.yaml ├── redis-sts.yaml ├── rolebinding.yaml ├── scheduler-sts.yaml ├── secret.yaml ├── serviceaccount.yaml ├── sqlproxy-sts.yaml ├── storage.yaml ├── svc.yaml ├── ui-sts.yaml └── worker-sts.yaml ├── test └── e2e │ ├── base_test.go │ ├── cluster_test.go │ └── gcp_test.go └── vendor └── sigs.k8s.io └── controller-reconciler └── pkg ├── finalizer ├── doc.go ├── finalizer.go ├── finalizer_suite_test.go ├── finalizer_test.go └── zz_generated.deepcopy.go ├── genericreconciler ├── doc.go ├── genericreconciler.go ├── genericreconciler_suite_test.go ├── genericreconciler_test.go ├── handler.go ├── types.go └── v1alpha1 │ ├── crfoo.go │ ├── doc.go │ ├── testutil.go │ └── zz_generated.deepcopy.go ├── reconciler ├── doc.go ├── manager │ ├── gcp │ │ ├── disk │ │ │ └── manager.go │ │ ├── gcs │ │ │ └── manager.go │ │ ├── redis │ │ │ └── manager.go │ │ └── utils.go │ ├── interface.go │ ├── internal.go │ ├── k8s │ │ └── manager.go │ └── types.go ├── resource.go ├── resource_suite_test.go ├── resource_test.go ├── testdata │ ├── sts.yaml │ └── unknown_rsrc.yaml └── types.go ├── status ├── condition.go ├── doc.go ├── status.go ├── status_suite_test.go ├── status_test.go ├── types.go └── zz_generated.deepcopy.go ├── storage ├── doc.go ├── storage.go ├── storage_suite_test.go ├── storage_test.go ├── types.go └── zz_generated.deepcopy.go └── test ├── framework.go └── helper.go /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | cover.out 3 | pkg/controller/airflowbase/templates 4 | pkg/controller/airflowcluster/templates 5 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Build the manager binary 2 | FROM golang:1.10.3 as builder 3 | 4 | # Copy in the go src 5 | WORKDIR /go/src/k8s.io/airflow-operator 6 | COPY pkg/ pkg/ 7 | COPY cmd/ cmd/ 8 | COPY vendor/ vendor/ 9 | 10 | # Build 11 | RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager k8s.io/airflow-operator/cmd/manager 12 | 13 | # Copy the controller-manager into a thin image 14 | FROM ubuntu:latest 15 | WORKDIR /root/ 16 | COPY --from=builder /go/src/k8s.io/airflow-operator/manager . 17 | COPY templates/ templates/ 18 | COPY config/crds/ crds/ 19 | ENTRYPOINT ["./manager"] 20 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | required = [ 2 | "github.com/emicklei/go-restful", 3 | "github.com/onsi/ginkgo", # for test framework 4 | "github.com/onsi/gomega", # for test matchers 5 | "k8s.io/client-go/plugin/pkg/client/auth/gcp", # for development against gcp 6 | "k8s.io/code-generator/cmd/client-gen", # for go generate 7 | "k8s.io/code-generator/cmd/deepcopy-gen", # for go generate 8 | "sigs.k8s.io/controller-tools/cmd/controller-gen", # for crd/rbac generation 9 | "sigs.k8s.io/controller-runtime/pkg/client/config", 10 | "sigs.k8s.io/controller-runtime/pkg/controller", 11 | "sigs.k8s.io/controller-runtime/pkg/handler", 12 | "sigs.k8s.io/controller-runtime/pkg/manager", 13 | "sigs.k8s.io/controller-runtime/pkg/runtime/signals", 14 | "sigs.k8s.io/controller-runtime/pkg/source", 15 | "sigs.k8s.io/testing_frameworks/integration", # for integration testing 16 | "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1", 17 | "google.golang.org/api/compute/v1", 18 | "google.golang.org/api/redis/v1", 19 | "google.golang.org/api/storage/v1", 20 | ] 21 | 22 | ignored=["sigs.k8s.io/controller-reconciler*", "github.com/kubernetes-sigs/controller-reconciler*"] 23 | 24 | [prune] 25 | go-tests = true 26 | 27 | #[[constraint]] 28 | # branch = "master" 29 | # name = "github.com/kubernetes-sigs/application" 30 | 31 | # STANZAS BELOW ARE GENERATED AND MAY BE WRITTEN - DO NOT MODIFY BELOW THIS LINE. 32 | 33 | [[constraint]] 34 | name="sigs.k8s.io/controller-runtime" 35 | version="v0.1.1" 36 | 37 | [[constraint]] 38 | name="sigs.k8s.io/controller-tools" 39 | version="v0.1.1" 40 | 41 | # For dependency below: Refer to issue https://github.com/golang/dep/issues/1799 42 | [[override]] 43 | name = "gopkg.in/fsnotify.v1" 44 | source = "https://github.com/fsnotify/fsnotify.git" 45 | version="v1.4.7" 46 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifndef NOTGCP 2 | PROJECT_ID := $(shell gcloud config get-value project) 3 | ZONE := $(shell gcloud config get-value compute/zone) 4 | SHORT_SHA := $(shell git rev-parse --short HEAD) 5 | IMG ?= gcr.io/${PROJECT_ID}/airflow-operator:${SHORT_SHA} 6 | endif 7 | 8 | # Image URL to use all building/pushing image targets 9 | 10 | all: test manager 11 | 12 | # Run tests 13 | test: generate fmt vet manifests 14 | ln -s ../../../templates/ pkg/controller/airflowbase/ || true 15 | ln -s ../../../templates/ pkg/controller/airflowcluster/ || true 16 | go test ./pkg/... ./cmd/... -coverprofile cover.out 17 | 18 | # Build manager binary 19 | manager: generate fmt vet 20 | go build -o bin/manager k8s.io/airflow-operator/cmd/manager 21 | 22 | # Run against the configured Kubernetes cluster in ~/.kube/config 23 | run: generate fmt vet 24 | go run ./cmd/manager/main.go 25 | 26 | # Run against the configured Kubernetes cluster in ~/.kube/config 27 | debug: generate fmt vet 28 | dlv debug cmd/manager/main.go 29 | 30 | # Install CRDs into a cluster 31 | install: manifests 32 | kubectl apply -f config/crds 33 | kubectl apply -f hack/appcrd.yaml 34 | 35 | # Deploy controller in the configured Kubernetes cluster in ~/.kube/config 36 | deploy: install 37 | kustomize build config/default | kubectl apply -f - 38 | 39 | # Deploy controller in the configured Kubernetes cluster in ~/.kube/config 40 | undeploy: manifests 41 | kustomize build config/default | kubectl delete -f - 42 | kubectl delete -f config/crds || true 43 | kubectl delete -f hack/appcrd.yaml || true 44 | 45 | # Generate manifests e.g. CRD, RBAC etc. 46 | manifests: 47 | go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all 48 | 49 | # Run go fmt against code 50 | fmt: 51 | go fmt ./pkg/... ./cmd/... 52 | 53 | # Run go vet against code 54 | vet: 55 | go vet ./pkg/... ./cmd/... 56 | 57 | # Generate code 58 | generate: 59 | echo ${IMG} 60 | go generate ./pkg/... ./cmd/... 61 | 62 | # Build the docker image 63 | docker-build: test 64 | docker build . -t ${IMG} 65 | @echo "updating kustomize image patch file for manager resource" 66 | sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml 67 | 68 | # Push the docker image 69 | docker-push: docker-build 70 | docker push ${IMG} 71 | 72 | 73 | e2e-test: 74 | kubectl get namespace airflowop-system || kubectl create namespace airflowop-system 75 | go test -v -timeout 20m test/e2e/base_test.go --namespace airflowop-system 76 | go test -v -timeout 20m test/e2e/cluster_test.go --namespace airflowop-system 77 | 78 | e2e-test-gcp: 79 | kubectl get namespace airflowop-system || kubectl create namespace airflowop-system 80 | kubectl apply -f hack/sample/cloudsql-celery/sqlproxy-secret.yaml -n airflowop-system 81 | go test -v -timeout 20m test/e2e/gcp_test.go --namespace airflowop-system 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Go Report Card](https://goreportcard.com/badge/github.com/GoogleCloudPlatform/airflow-operator)](https://goreportcard.com/report/github.com/GoogleCloudPlatform/airflow-operator) 2 | 3 | **This is not an officially supported Google product.** 4 | 5 | ## Community 6 | 7 | * Join our [Slack channel](https://kubernetes.slack.com/messages/CC1UAMYSV). 8 | 9 | ## Project Status 10 | 11 | *Alpha* 12 | 13 | The Airflow Operator is still under active development and has not been extensively tested in production environment. Backward compatibility of the APIs is not guaranteed for alpha releases. 14 | 15 | ## Prerequisites 16 | * Version >= 1.9 of Kubernetes. 17 | * Uses 1.9 of Airflow (1.10.1+ for k8s executor) 18 | * Uses 4.0.x of Redis (for celery operator) 19 | * Uses 5.7 of MySQL 20 | 21 | ## Get Started 22 | 23 | [One Click Deployment](https://console.cloud.google.com/marketplace/details/google/airflow-operator) from Google Cloud Marketplace to your [GKE cluster](https://cloud.google.com/kubernetes-engine/) 24 | 25 | Get started quickly with the Airflow Operator using the [Quick Start Guide](https://github.com/GoogleCloudPlatform/airflow-operator/blob/master/docs/quickstart.md) 26 | 27 | For more information check the [Design](https://github.com/GoogleCloudPlatform/airflow-operator/blob/master/docs/design.md) and detailed [User Guide](https://github.com/GoogleCloudPlatform/airflow-operator/blob/master/docs/userguide.md) 28 | 29 | ## Airflow Operator Overview 30 | Airflow Operator is a custom [Kubernetes operator](https://coreos.com/blog/introducing-operators.html) that makes it easy to deploy and manage [Apache Airflow](https://airflow.apache.org/) on Kubernetes. Apache Airflow is a platform to programmatically author, schedule and monitor workflows. Using the Airflow Operator, an Airflow cluster is split into 2 parts represented by the `AirflowBase` and `AirflowCluster` custom resources. 31 | The Airflow Operator performs these jobs: 32 | * Creates and manages the necessary Kubernetes resources for an Airflow deployment. 33 | * Updates the corresponding Kubernetes resources when the `AirflowBase` or `AirflowCluster` specification changes. 34 | * Restores managed Kubernetes resources that are deleted. 35 | * Supports creation of Airflow schedulers with different Executors 36 | * Supports sharing of the `AirflowBase` across mulitple `AirflowClusters` 37 | 38 | Checkout out the [Design](https://github.com/GoogleCloudPlatform/airflow-operator/blob/master/docs/design.md) 39 | 40 | ![Airflow Cluster](docs/airflow-cluster.png) 41 | 42 | 43 | ## Development 44 | 45 | Refer to the [Design](https://github.com/GoogleCloudPlatform/airflow-operator/blob/master/docs/design.md) and [Development Guide](https://github.com/GoogleCloudPlatform/airflow-operator/blob/master/docs/development.md). 46 | 47 | ## Managed Airflow solution 48 | 49 | [Google Cloud Composer](https://cloud.google.com/composer/) is a fully managed workflow orchestration service targeting customers that need a workflow manager in the cloud. 50 | -------------------------------------------------------------------------------- /cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | # Google Cloud Build script 19 | # 20 | 21 | steps: 22 | - name: 'gcr.io/cloud-builders/docker' 23 | args: ['build', '.', '-t', 'gcr.io/airflow-operator/airflow-operator:v1alpha2', '-t', 'gcr.io/airflow-operator/airflow-operator:$REVISION_ID', '-f', 'Dockerfile' ] 24 | 25 | images: ['gcr.io/airflow-operator/airflow-operator:v1alpha2', 'gcr.io/airflow-operator/airflow-operator:$REVISION_ID'] 26 | -------------------------------------------------------------------------------- /cmd/manager/main.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package main 17 | 18 | import ( 19 | "os" 20 | 21 | "k8s.io/airflow-operator/pkg/apis" 22 | "k8s.io/airflow-operator/pkg/controller" 23 | "k8s.io/airflow-operator/pkg/webhook" 24 | _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" 25 | "sigs.k8s.io/controller-runtime/pkg/client/config" 26 | "sigs.k8s.io/controller-runtime/pkg/manager" 27 | logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" 28 | "sigs.k8s.io/controller-runtime/pkg/runtime/signals" 29 | "time" 30 | ) 31 | 32 | func main() { 33 | logf.SetLogger(logf.ZapLogger(false)) 34 | log := logf.Log.WithName("entrypoint") 35 | 36 | // Get a config to talk to the apiserver 37 | log.Info("setting up client for manager") 38 | cfg, err := config.GetConfig() 39 | if err != nil { 40 | log.Error(err, "unable to set up client config") 41 | os.Exit(1) 42 | } 43 | 44 | // Create a new Cmd to provide shared dependencies and start components 45 | log.Info("setting up manager") 46 | syncperiod := time.Minute * 2 47 | mgr, err := manager.New(cfg, manager.Options{SyncPeriod: &syncperiod}) 48 | if err != nil { 49 | log.Error(err, "unable to set up overall controller manager") 50 | os.Exit(1) 51 | } 52 | 53 | log.Info("Registering Components.") 54 | 55 | // Setup Scheme for all resources 56 | log.Info("setting up scheme") 57 | if err := apis.AddToScheme(mgr.GetScheme()); err != nil { 58 | log.Error(err, "unable add APIs to scheme") 59 | os.Exit(1) 60 | } 61 | 62 | // Setup all Controllers 63 | log.Info("Setting up controller") 64 | if err := controller.AddToManager(mgr); err != nil { 65 | log.Error(err, "unable to register controllers to the manager") 66 | os.Exit(1) 67 | } 68 | 69 | log.Info("setting up webhooks") 70 | if err := webhook.AddToManager(mgr); err != nil { 71 | log.Error(err, "unable to register webhooks to the manager") 72 | os.Exit(1) 73 | } 74 | 75 | // Start the Cmd 76 | log.Info("Starting the Cmd.") 77 | if err := mgr.Start(signals.SetupSignalHandler()); err != nil { 78 | log.Error(err, "unable to run the manager") 79 | os.Exit(1) 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /config/default/kustomization.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | # Adds namespace to all resources. 18 | namespace: airflowop-system 19 | 20 | # Value of this field is prepended to the 21 | # names of all resources, e.g. a deployment named 22 | # "wordpress" becomes "alices-wordpress". 23 | # Note that it should also match with the prefix (text before '-') of the namespace 24 | # field above. 25 | namePrefix: airflowop- 26 | 27 | # Labels to add to all resources and selectors. 28 | #commonLabels: 29 | # someName: someValue 30 | 31 | # Each entry in this list must resolve to an existing 32 | # resource definition in YAML. These are the resource 33 | # files that kustomize reads, modifies and emits as a 34 | # YAML string, with resources separated by document 35 | # markers ("---"). 36 | resources: 37 | - ./rbac/rbac_role.yaml 38 | - ./rbac/rbac_role_binding.yaml 39 | - ./manager/manager.yaml 40 | 41 | patches: 42 | - manager_image_patch.yaml 43 | 44 | vars: 45 | - name: WEBHOOK_SECRET_NAME 46 | objref: 47 | kind: Secret 48 | name: webhook-server-secret 49 | apiVersion: v1 50 | -------------------------------------------------------------------------------- /config/default/manager/manager.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: v1 18 | kind: Namespace 19 | metadata: 20 | labels: 21 | controller-tools.k8s.io: "1.0" 22 | name: system 23 | --- 24 | apiVersion: v1 25 | kind: Service 26 | metadata: 27 | name: controller-manager-service 28 | namespace: system 29 | labels: 30 | control-plane: controller-manager 31 | controller-tools.k8s.io: "1.0" 32 | spec: 33 | selector: 34 | control-plane: controller-manager 35 | controller-tools.k8s.io: "1.0" 36 | ports: 37 | - port: 443 38 | --- 39 | apiVersion: apps/v1 40 | kind: StatefulSet 41 | metadata: 42 | name: controller-manager 43 | namespace: system 44 | labels: 45 | control-plane: controller-manager 46 | controller-tools.k8s.io: "1.0" 47 | spec: 48 | selector: 49 | matchLabels: 50 | control-plane: controller-manager 51 | controller-tools.k8s.io: "1.0" 52 | serviceName: controller-manager-service 53 | template: 54 | metadata: 55 | labels: 56 | control-plane: controller-manager 57 | controller-tools.k8s.io: "1.0" 58 | spec: 59 | containers: 60 | - command: 61 | - /root/manager 62 | image: controller:latest 63 | imagePullPolicy: Always 64 | name: manager 65 | env: 66 | - name: POD_NAMESPACE 67 | valueFrom: 68 | fieldRef: 69 | fieldPath: metadata.namespace 70 | - name: SECRET_NAME 71 | value: $(WEBHOOK_SECRET_NAME) 72 | resources: 73 | limits: 74 | cpu: 100m 75 | memory: 30Mi 76 | requests: 77 | cpu: 100m 78 | memory: 20Mi 79 | ports: 80 | - containerPort: 9876 81 | name: webhook-server 82 | protocol: TCP 83 | volumeMounts: 84 | - mountPath: /tmp/cert 85 | name: cert 86 | readOnly: true 87 | terminationGracePeriodSeconds: 10 88 | volumes: 89 | - name: cert 90 | secret: 91 | defaultMode: 420 92 | secretName: webhook-server-secret 93 | --- 94 | apiVersion: v1 95 | kind: Secret 96 | metadata: 97 | name: webhook-server-secret 98 | namespace: system 99 | -------------------------------------------------------------------------------- /config/default/manager_image_patch.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: apps/v1 18 | kind: StatefulSet 19 | metadata: 20 | name: controller-manager 21 | namespace: system 22 | spec: 23 | template: 24 | spec: 25 | containers: 26 | # Change the value of image field below to your controller image URL 27 | - image: gcr.io/kubeflow-193622/airflow-operator:db92567 28 | name: manager 29 | --- 30 | apiVersion: rbac.authorization.k8s.io/v1 31 | kind: ClusterRoleBinding 32 | metadata: 33 | name: manager-rolebinding 34 | roleRef: 35 | apiGroup: rbac.authorization.k8s.io 36 | kind: ClusterRole 37 | name: cluster-admin 38 | -------------------------------------------------------------------------------- /config/default/rbac/rbac_role.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: rbac.authorization.k8s.io/v1 18 | kind: ClusterRole 19 | metadata: 20 | creationTimestamp: null 21 | name: manager-role 22 | rules: 23 | - apiGroups: 24 | - apps 25 | resources: 26 | - statefulsets 27 | verbs: 28 | - get 29 | - list 30 | - watch 31 | - create 32 | - update 33 | - patch 34 | - delete 35 | - apiGroups: 36 | - "" 37 | resources: 38 | - services 39 | verbs: 40 | - get 41 | - list 42 | - watch 43 | - create 44 | - update 45 | - patch 46 | - delete 47 | - apiGroups: 48 | - "" 49 | resources: 50 | - configmaps 51 | verbs: 52 | - get 53 | - list 54 | - watch 55 | - create 56 | - update 57 | - patch 58 | - delete 59 | - apiGroups: 60 | - airflow.k8s.io 61 | resources: 62 | - airflowbases 63 | verbs: 64 | - get 65 | - list 66 | - watch 67 | - create 68 | - update 69 | - patch 70 | - delete 71 | - apiGroups: 72 | - airflow.k8s.io 73 | resources: 74 | - airflowclusters 75 | verbs: 76 | - get 77 | - list 78 | - watch 79 | - create 80 | - update 81 | - patch 82 | - delete 83 | - apiGroups: 84 | - app.k8s.io 85 | resources: 86 | - applications 87 | verbs: 88 | - get 89 | - list 90 | - watch 91 | - create 92 | - update 93 | - patch 94 | - delete 95 | - apiGroups: 96 | - policy 97 | resources: 98 | - poddisruptionbudgets 99 | verbs: 100 | - get 101 | - list 102 | - watch 103 | - create 104 | - update 105 | - patch 106 | - delete 107 | - apiGroups: 108 | - rbac.authorization.k8s.io 109 | resources: 110 | - rolebindings 111 | verbs: 112 | - get 113 | - list 114 | - watch 115 | - create 116 | - update 117 | - patch 118 | - delete 119 | - apiGroups: 120 | - "" 121 | resources: 122 | - secrets 123 | verbs: 124 | - get 125 | - list 126 | - watch 127 | - create 128 | - update 129 | - patch 130 | - delete 131 | - apiGroups: 132 | - "" 133 | resources: 134 | - serviceaccounts 135 | verbs: 136 | - get 137 | - list 138 | - watch 139 | - create 140 | - update 141 | - patch 142 | - delete 143 | - apiGroups: 144 | - storage.k8s.io 145 | resources: 146 | - storageclasses 147 | verbs: 148 | - get 149 | - list 150 | - watch 151 | - create 152 | - update 153 | - patch 154 | - delete 155 | - apiGroups: 156 | - admissionregistration.k8s.io 157 | resources: 158 | - mutatingwebhookconfigurations 159 | - validatingwebhookconfigurations 160 | verbs: 161 | - get 162 | - list 163 | - watch 164 | - create 165 | - update 166 | - patch 167 | - delete 168 | - apiGroups: 169 | - "" 170 | resources: 171 | - secrets 172 | verbs: 173 | - get 174 | - list 175 | - watch 176 | - create 177 | - update 178 | - patch 179 | - delete 180 | - apiGroups: 181 | - "" 182 | resources: 183 | - services 184 | verbs: 185 | - get 186 | - list 187 | - watch 188 | - create 189 | - update 190 | - patch 191 | - delete 192 | -------------------------------------------------------------------------------- /config/default/rbac/rbac_role_binding.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: rbac.authorization.k8s.io/v1 18 | kind: ClusterRoleBinding 19 | metadata: 20 | creationTimestamp: null 21 | name: manager-rolebinding 22 | roleRef: 23 | apiGroup: rbac.authorization.k8s.io 24 | kind: ClusterRole 25 | name: manager-role 26 | subjects: 27 | - kind: ServiceAccount 28 | name: default 29 | namespace: system 30 | -------------------------------------------------------------------------------- /config/rbac/rbac_role.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: rbac.authorization.k8s.io/v1 18 | kind: ClusterRole 19 | metadata: 20 | creationTimestamp: null 21 | name: manager-role 22 | rules: 23 | - apiGroups: 24 | - apps 25 | resources: 26 | - statefulsets 27 | verbs: 28 | - get 29 | - list 30 | - watch 31 | - create 32 | - update 33 | - patch 34 | - delete 35 | - apiGroups: 36 | - "" 37 | resources: 38 | - services 39 | verbs: 40 | - get 41 | - list 42 | - watch 43 | - create 44 | - update 45 | - patch 46 | - delete 47 | - apiGroups: 48 | - "" 49 | resources: 50 | - configmaps 51 | verbs: 52 | - get 53 | - list 54 | - watch 55 | - create 56 | - update 57 | - patch 58 | - delete 59 | - apiGroups: 60 | - airflow.k8s.io 61 | resources: 62 | - airflowbases 63 | verbs: 64 | - get 65 | - list 66 | - watch 67 | - create 68 | - update 69 | - patch 70 | - delete 71 | - apiGroups: 72 | - airflow.k8s.io 73 | resources: 74 | - airflowclusters 75 | verbs: 76 | - get 77 | - list 78 | - watch 79 | - create 80 | - update 81 | - patch 82 | - delete 83 | - apiGroups: 84 | - app.k8s.io 85 | resources: 86 | - applications 87 | verbs: 88 | - get 89 | - list 90 | - watch 91 | - create 92 | - update 93 | - patch 94 | - delete 95 | - apiGroups: 96 | - policy 97 | resources: 98 | - poddisruptionbudgets 99 | verbs: 100 | - get 101 | - list 102 | - watch 103 | - create 104 | - update 105 | - patch 106 | - delete 107 | - apiGroups: 108 | - rbac.authorization.k8s.io 109 | resources: 110 | - rolebindings 111 | verbs: 112 | - get 113 | - list 114 | - watch 115 | - create 116 | - update 117 | - patch 118 | - delete 119 | - apiGroups: 120 | - "" 121 | resources: 122 | - secrets 123 | verbs: 124 | - get 125 | - list 126 | - watch 127 | - create 128 | - update 129 | - patch 130 | - delete 131 | - apiGroups: 132 | - "" 133 | resources: 134 | - serviceaccounts 135 | verbs: 136 | - get 137 | - list 138 | - watch 139 | - create 140 | - update 141 | - patch 142 | - delete 143 | - apiGroups: 144 | - storage.k8s.io 145 | resources: 146 | - storageclasses 147 | verbs: 148 | - get 149 | - list 150 | - watch 151 | - create 152 | - update 153 | - patch 154 | - delete 155 | - apiGroups: 156 | - admissionregistration.k8s.io 157 | resources: 158 | - mutatingwebhookconfigurations 159 | - validatingwebhookconfigurations 160 | verbs: 161 | - get 162 | - list 163 | - watch 164 | - create 165 | - update 166 | - patch 167 | - delete 168 | - apiGroups: 169 | - "" 170 | resources: 171 | - secrets 172 | verbs: 173 | - get 174 | - list 175 | - watch 176 | - create 177 | - update 178 | - patch 179 | - delete 180 | - apiGroups: 181 | - "" 182 | resources: 183 | - services 184 | verbs: 185 | - get 186 | - list 187 | - watch 188 | - create 189 | - update 190 | - patch 191 | - delete 192 | -------------------------------------------------------------------------------- /config/rbac/rbac_role_binding.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: rbac.authorization.k8s.io/v1 18 | kind: ClusterRoleBinding 19 | metadata: 20 | creationTimestamp: null 21 | name: manager-rolebinding 22 | roleRef: 23 | apiGroup: rbac.authorization.k8s.io 24 | kind: ClusterRole 25 | name: manager-role 26 | subjects: 27 | - kind: ServiceAccount 28 | name: default 29 | namespace: system 30 | -------------------------------------------------------------------------------- /config/samples/airflow_v1alpha1_airflowbase.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: airflow.k8s.io/v1alpha1 18 | kind: AirflowBase 19 | metadata: 20 | labels: 21 | controller-tools.k8s.io: "1.0" 22 | name: airflowbase-sample 23 | spec: 24 | # Add fields here 25 | foo: bar 26 | -------------------------------------------------------------------------------- /config/samples/airflow_v1alpha1_airflowcluster.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: airflow.k8s.io/v1alpha1 18 | kind: AirflowCluster 19 | metadata: 20 | labels: 21 | controller-tools.k8s.io: "1.0" 22 | name: airflowcluster-sample 23 | spec: 24 | # Add fields here 25 | foo: bar 26 | -------------------------------------------------------------------------------- /docs/airflow-base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/airflow-operator/13d25fa355d833d01cab69dec647d75cfe02cc3e/docs/airflow-base.png -------------------------------------------------------------------------------- /docs/airflow-cluster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/airflow-operator/13d25fa355d833d01cab69dec647d75cfe02cc3e/docs/airflow-cluster.png -------------------------------------------------------------------------------- /docs/airflow-multi-node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/airflow-operator/13d25fa355d833d01cab69dec647d75cfe02cc3e/docs/airflow-multi-node.png -------------------------------------------------------------------------------- /docs/airflow-pod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/airflow-operator/13d25fa355d833d01cab69dec647d75cfe02cc3e/docs/airflow-pod.png -------------------------------------------------------------------------------- /docs/airflow-region-spread.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/airflow-operator/13d25fa355d833d01cab69dec647d75cfe02cc3e/docs/airflow-region-spread.png -------------------------------------------------------------------------------- /docs/airflow-zone-spread.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/airflow-operator/13d25fa355d833d01cab69dec647d75cfe02cc3e/docs/airflow-zone-spread.png -------------------------------------------------------------------------------- /docs/development.md: -------------------------------------------------------------------------------- 1 | # Development 2 | You should have kubeconfig setup to point to your cluster. 3 | In case you want to build the Airflow Operator from the source code, e.g., to test a fix or a feature you write, you can do so following the instructions below. 4 | 5 | ## Cloning the repo: 6 | ```bash 7 | $ mkdir -p $GOPATH/src/k8s.io 8 | $ cd $GOPATH/src/k8s.io 9 | $ git clone git@github.com:GoogleCloudPlatform/airflow-operator.git 10 | ``` 11 | 12 | ## Building and running locally: 13 | ```bash 14 | # build 15 | make build 16 | 17 | # run locally 18 | make run 19 | ``` 20 | ## Building docker image 21 | #### GCP 22 | When working with GCP ensure that gcloud is setup and gcr(container registry) is enabled for the current project. 23 | If not set IMG env to point to the desired registry image. 24 | ```bash 25 | # building docker image 26 | make docker-build 27 | 28 | # push docker image 29 | make docker-push 30 | ``` 31 | 32 | 33 | ### Non GCP 34 | Set IMG env to point to the desired registry image. 35 | ```bash 36 | # building docker image 37 | make docker-build NOTGCP=true 38 | 39 | # push docker image 40 | make docker-push NOTGCP=true 41 | ``` 42 | ## Running in cluster 43 | ```bash 44 | # assumes kubeconfig is setup correctly 45 | make deploy 46 | ``` 47 | 48 | 49 | ## Tests 50 | 51 | ### Running local tests 52 | Runs unit-tests locally 53 | 54 | ```bash 55 | make test 56 | ``` 57 | 58 | ### Running e2e tests 59 | Before running e2e tests ensure that the desrired version is running on the cluster or locally. 60 | 61 | ```bash 62 | # Start controller in cluster: 63 | # make docker-push 64 | # make deploy 65 | # OR locally: 66 | # make install 67 | # make run 68 | # and then run the tests 69 | 70 | make e2e-test 71 | ``` 72 | -------------------------------------------------------------------------------- /docs/userguide.md: -------------------------------------------------------------------------------- 1 | # User Guide 2 | 3 | TODO 4 | 5 | # FAQs 6 | 7 | 1. How do we refresh DAGs ? 8 | Canonical way airflow supports refreshing DAGs is via `dag_dir_list_interval` config. 9 | https://cwiki.apache.org/confluence/display/AIRFLOW/Scheduler+Basics#Configuration 10 | You can set that config using `cluster.spec.config.airflow` 11 | Set the env `AIRFLOW__SCHEDULER__ DAG_DIR_LIST_INTERVAL` 12 | By default dags are refreshed every 5 minutes. 13 | To enable continuous sync, use git or gcs dag source with once disabled. 14 | 15 | ```yaml 16 | apiVersion: airflow.k8s.io/v1alpha1 17 | kind: AirflowCluster 18 | ... 19 | spec: 20 | ... 21 | config: 22 | airflow: 23 | AIRFLOW__SCHEDULER__DAG_DIR_LIST_INTERVAL: 100 # default is 300s 24 | ... 25 | dags: 26 | subdir: "" 27 | gcs: 28 | bucket: "mydags" 29 | # OR 30 | dags: 31 | subdir: "airflow/example_dags/" 32 | git: 33 | repo: "https://github.com/apache/incubator-airflow/" 34 | once: false 35 | ``` 36 | 37 | 38 | -------------------------------------------------------------------------------- /hack/appcrd.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: apiextensions.k8s.io/v1beta1 18 | kind: CustomResourceDefinition 19 | metadata: 20 | creationTimestamp: null 21 | labels: 22 | api: default 23 | kubebuilder.k8s.io: 0.1.10 24 | name: applications.app.k8s.io 25 | spec: 26 | group: app.k8s.io 27 | names: 28 | kind: Application 29 | plural: applications 30 | scope: Namespaced 31 | validation: 32 | openAPIV3Schema: 33 | properties: 34 | apiVersion: 35 | type: string 36 | kind: 37 | type: string 38 | metadata: 39 | type: object 40 | spec: 41 | type: object 42 | properties: 43 | selector: 44 | type: object 45 | assemblyPhase: 46 | type: string 47 | componentKinds: 48 | items: 49 | type: object 50 | type: array 51 | description: 52 | type: string 53 | info: 54 | items: 55 | properties: 56 | name: 57 | type: string 58 | type: 59 | type: string 60 | value: 61 | type: string 62 | valueFrom: 63 | properties: 64 | configMapKeyRef: 65 | properties: 66 | key: 67 | type: string 68 | type: object 69 | ingressRef: 70 | properties: 71 | host: 72 | type: string 73 | path: 74 | type: string 75 | type: object 76 | secretKeyRef: 77 | properties: 78 | key: 79 | type: string 80 | type: object 81 | serviceRef: 82 | properties: 83 | path: 84 | type: string 85 | port: 86 | type: int32 87 | type: object 88 | type: 89 | type: string 90 | type: object 91 | type: object 92 | type: array 93 | descriptor: 94 | type: object 95 | properties: 96 | keywords: 97 | items: 98 | type: string 99 | type: array 100 | links: 101 | items: 102 | properties: 103 | description: 104 | type: string 105 | url: 106 | type: string 107 | type: object 108 | type: array 109 | maintainers: 110 | items: 111 | properties: 112 | email: 113 | type: string 114 | name: 115 | type: string 116 | url: 117 | type: string 118 | type: object 119 | type: array 120 | notes: 121 | type: string 122 | owners: 123 | items: 124 | type: string 125 | type: array 126 | type: 127 | type: string 128 | version: 129 | type: string 130 | status: 131 | properties: 132 | observedGeneration: 133 | type: int64 134 | type: object 135 | type: object 136 | version: v1beta1 137 | status: 138 | acceptedNames: 139 | kind: "" 140 | plural: "" 141 | conditions: [] 142 | storedVersions: [] 143 | -------------------------------------------------------------------------------- /hack/boilerplate.go.txt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ -------------------------------------------------------------------------------- /hack/sample/cloudsql-celery/base.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: airflow.k8s.io/v1alpha1 18 | kind: AirflowBase 19 | metadata: 20 | name: cc-base 21 | spec: 22 | sqlproxy: 23 | project: kubeflow-193622 24 | region: us-central1 25 | instance: airflow-test1 26 | type: postgres 27 | storage: 28 | version: "" 29 | -------------------------------------------------------------------------------- /hack/sample/cloudsql-celery/cluster.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: airflow.k8s.io/v1alpha1 19 | kind: AirflowCluster 20 | metadata: 21 | name: cc-cluster 22 | spec: 23 | executor: Celery 24 | redis: 25 | operator: False 26 | scheduler: 27 | version: "1.10.2" 28 | ui: 29 | replicas: 1 30 | version: "1.10.2" 31 | worker: 32 | replicas: 2 33 | version: "1.10.2" 34 | flower: 35 | replicas: 1 36 | version: "1.10.2" 37 | dags: 38 | subdir: "airflow/example_dags/" 39 | git: 40 | repo: "https://github.com/apache/incubator-airflow/" 41 | once: true 42 | airflowbase: 43 | name: cc-base 44 | -------------------------------------------------------------------------------- /hack/sample/cloudsql-celery/sqlproxy-secret.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: v1 19 | kind: Secret 20 | metadata: 21 | name: cc-base-sql 22 | type: Opaque 23 | data: 24 | rootpassword: cm9vdDEyMw== 25 | -------------------------------------------------------------------------------- /hack/sample/cloudsql-k8s/cluster.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: airflow.k8s.io/v1alpha1 19 | kind: AirflowCluster 20 | metadata: 21 | name: ck-cluster 22 | spec: 23 | executor: Kubernetes 24 | ui: 25 | replicas: 1 26 | version: "1.10.2" 27 | scheduler: 28 | version: "1.10.2" 29 | worker: 30 | version: "1.10.2" 31 | dags: 32 | subdir: "airflow/example_dags/" 33 | git: 34 | repo: "https://github.com/apache/incubator-airflow/" 35 | once: true 36 | branch: master 37 | airflowbase: 38 | name: cc-base 39 | -------------------------------------------------------------------------------- /hack/sample/cloudsql-local/cluster.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: airflow.k8s.io/v1alpha1 18 | kind: AirflowCluster 19 | metadata: 20 | name: cl-cluster 21 | spec: 22 | executor: Local 23 | scheduler: 24 | version: "1.10.2" 25 | ui: 26 | replicas: 1 27 | version: "1.10.2" 28 | airflowbase: 29 | name: cc-base 30 | -------------------------------------------------------------------------------- /hack/sample/mysql-celery-gcs/cluster.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: airflow.k8s.io/v1alpha1 19 | kind: AirflowCluster 20 | metadata: 21 | name: mcg-cluster 22 | spec: 23 | executor: Celery 24 | redis: 25 | operator: False 26 | scheduler: 27 | version: "1.10.2" 28 | ui: 29 | replicas: 1 30 | version: "1.10.2" 31 | flower: 32 | replicas: 1 33 | version: "1.10.2" 34 | worker: 35 | replicas: 2 36 | version: "1.10.2" 37 | dags: 38 | subdir: "" 39 | gcs: 40 | bucket: "mydags" 41 | airflowbase: 42 | name: mc-base 43 | -------------------------------------------------------------------------------- /hack/sample/mysql-celery/base.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: airflow.k8s.io/v1alpha1 19 | kind: AirflowBase 20 | metadata: 21 | name: mc-base 22 | spec: 23 | mysql: 24 | operator: False 25 | storage: 26 | version: "" 27 | -------------------------------------------------------------------------------- /hack/sample/mysql-celery/cluster.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: airflow.k8s.io/v1alpha1 19 | kind: AirflowCluster 20 | metadata: 21 | name: mc-cluster 22 | spec: 23 | executor: Celery 24 | config: 25 | airflow: 26 | AIRFLOW_SOME_CONFIG: SomeValue 27 | redis: 28 | operator: False 29 | scheduler: 30 | version: "1.10.2" 31 | ui: 32 | replicas: 1 33 | version: "1.10.2" 34 | worker: 35 | replicas: 2 36 | version: "1.10.2" 37 | flower: 38 | replicas: 1 39 | version: "1.10.2" 40 | dags: 41 | subdir: "airflow/example_dags/" 42 | git: 43 | repo: "https://github.com/apache/incubator-airflow/" 44 | once: true 45 | airflowbase: 46 | name: mc-base 47 | -------------------------------------------------------------------------------- /hack/sample/mysql-k8s/cluster.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: airflow.k8s.io/v1alpha1 19 | kind: AirflowCluster 20 | metadata: 21 | name: mk-cluster 22 | spec: 23 | executor: Kubernetes 24 | ui: 25 | replicas: 1 26 | version: "1.10.2" 27 | scheduler: 28 | version: "1.10.2" 29 | worker: 30 | #image: "gcr.io/airflow-development-225219/airflow" 31 | #version: "demo-nr4" 32 | version: "1.10.2" 33 | dags: 34 | subdir: "airflow/example_dags/" 35 | git: 36 | repo: "https://github.com/apache/incubator-airflow/" 37 | once: true 38 | branch: master 39 | airflowbase: 40 | name: mc-base 41 | -------------------------------------------------------------------------------- /hack/sample/mysql-local/cluster.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: airflow.k8s.io/v1alpha1 19 | kind: AirflowCluster 20 | metadata: 21 | name: ml-cluster 22 | spec: 23 | executor: Local 24 | scheduler: 25 | version: "1.10.2" 26 | ui: 27 | replicas: 1 28 | version: "1.10.2" 29 | airflowbase: 30 | name: mc-base 31 | # config: 32 | #airflow: 33 | # AIRFLOW__SCHEDULER__DAG_DIR_LIST_INTERVAL: "100" 34 | # AIRFLOW__WEBSERVER__AUTHENTICATE: "True" 35 | # AIRFLOW__WEBSERVER__AUTH_BACKEND: "airflow.contrib.auth.backends.password_auth" 36 | -------------------------------------------------------------------------------- /hack/sample/postgres-celery-memorystore/cluster.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: airflow.k8s.io/v1alpha1 19 | kind: AirflowCluster 20 | metadata: 21 | name: pc-cluster 22 | spec: 23 | executor: Celery 24 | memoryStore: 25 | project: "project-id" 26 | region: "region-id" 27 | memorySizeGb: 1 28 | tier: "basic" 29 | maxMemoryPolicy: "allkeys-lru" 30 | scheduler: 31 | version: "1.10.2" 32 | ui: 33 | replicas: 1 34 | version: "1.10.2" 35 | worker: 36 | replicas: 2 37 | version: "1.10.2" 38 | flower: 39 | replicas: 1 40 | version: "1.10.2" 41 | dags: 42 | subdir: "airflow/example_dags/" 43 | git: 44 | repo: "https://github.com/apache/incubator-airflow/" 45 | once: true 46 | airflowbase: 47 | name: pc-base 48 | -------------------------------------------------------------------------------- /hack/sample/postgres-celery-redis/cluster.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: airflow.k8s.io/v1alpha1 19 | kind: AirflowCluster 20 | metadata: 21 | name: pc-cluster 22 | spec: 23 | executor: Celery 24 | redis: 25 | operator: False 26 | redisHost: "redis" 27 | redisPassword: True 28 | scheduler: 29 | version: "1.10.2" 30 | ui: 31 | replicas: 1 32 | version: "1.10.2" 33 | worker: 34 | replicas: 2 35 | version: "1.10.2" 36 | flower: 37 | replicas: 1 38 | version: "1.10.2" 39 | dags: 40 | subdir: "airflow/example_dags/" 41 | git: 42 | repo: "https://github.com/apache/incubator-airflow/" 43 | once: true 44 | airflowbase: 45 | name: pc-base 46 | -------------------------------------------------------------------------------- /hack/sample/postgres-celery-redis/redis-secret.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: v1 19 | kind: Secret 20 | metadata: 21 | name: pc-cluster-redis 22 | type: Opaque 23 | data: 24 | password: aGVsbG93b3JsZA== 25 | -------------------------------------------------------------------------------- /hack/sample/postgres-celery-redis/redis.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: v1 19 | kind: Service 20 | metadata: 21 | name: redis 22 | spec: 23 | ports: 24 | - port: 6379 25 | name: redis 26 | selector: 27 | app: redis 28 | --- 29 | apiVersion: apps/v1beta2 30 | kind: StatefulSet 31 | metadata: 32 | name: redis 33 | spec: 34 | selector: 35 | matchLabels: 36 | app: redis # has to match .spec.template.metadata.labels 37 | serviceName: redis 38 | replicas: 1 39 | template: 40 | metadata: 41 | labels: 42 | app: redis # has to match .spec.selector.matchLabels 43 | spec: 44 | containers: 45 | - name: redis 46 | image: redis:4.0 47 | imagePullPolicy: Always 48 | args: 49 | - --requirepass 50 | - $(REDIS_PASSWORD) 51 | env: 52 | - name: REDIS_PASSWORD 53 | valueFrom: 54 | secretKeyRef: 55 | key: password 56 | name: pc-cluster-redis 57 | ports: 58 | - containerPort: 6379 59 | name: redis 60 | -------------------------------------------------------------------------------- /hack/sample/postgres-celery/base.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: airflow.k8s.io/v1alpha1 19 | kind: AirflowBase 20 | metadata: 21 | name: pc-base 22 | spec: 23 | postgres: 24 | operator: False 25 | storage: 26 | version: "" 27 | -------------------------------------------------------------------------------- /hack/sample/postgres-celery/cluster.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: airflow.k8s.io/v1alpha1 19 | kind: AirflowCluster 20 | metadata: 21 | name: pc-cluster 22 | spec: 23 | executor: Celery 24 | redis: 25 | operator: False 26 | scheduler: 27 | version: "1.10.2" 28 | ui: 29 | replicas: 1 30 | version: "1.10.2" 31 | worker: 32 | replicas: 2 33 | version: "1.10.2" 34 | flower: 35 | replicas: 1 36 | version: "1.10.2" 37 | dags: 38 | subdir: "airflow/example_dags/" 39 | git: 40 | repo: "https://github.com/apache/incubator-airflow/" 41 | once: true 42 | airflowbase: 43 | name: pc-base 44 | -------------------------------------------------------------------------------- /hack/sample/postgres-k8s/cluster.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: airflow.k8s.io/v1alpha1 19 | kind: AirflowCluster 20 | metadata: 21 | name: pk-cluster 22 | spec: 23 | executor: Kubernetes 24 | ui: 25 | replicas: 1 26 | version: "1.10.2" 27 | scheduler: 28 | version: "1.10.2" 29 | worker: 30 | version: "1.10.2" 31 | dags: 32 | subdir: "airflow/example_dags/" 33 | git: 34 | repo: "https://github.com/apache/incubator-airflow/" 35 | once: true 36 | branch: master 37 | airflowbase: 38 | name: pc-base 39 | -------------------------------------------------------------------------------- /hack/sample/postgres-local/cluster.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | apiVersion: airflow.k8s.io/v1alpha1 19 | kind: AirflowCluster 20 | metadata: 21 | name: pl-cluster 22 | spec: 23 | executor: Local 24 | ui: 25 | replicas: 1 26 | version: "1.10.2" 27 | scheduler: 28 | version: "1.10.2" 29 | airflowbase: 30 | name: pc-base 31 | -------------------------------------------------------------------------------- /pkg/apis/addtoscheme_airflow_v1alpha1.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package apis 17 | 18 | import ( 19 | "k8s.io/airflow-operator/pkg/apis/airflow/v1alpha1" 20 | ) 21 | 22 | func init() { 23 | // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back 24 | AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/apis/airflow/group.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package airflow contains airflow API versions 17 | package airflow 18 | -------------------------------------------------------------------------------- /pkg/apis/airflow/v1alpha1/airflowbase_types_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package v1alpha1 17 | 18 | import ( 19 | "testing" 20 | 21 | "github.com/onsi/gomega" 22 | "golang.org/x/net/context" 23 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 | "k8s.io/apimachinery/pkg/types" 25 | ) 26 | 27 | func TestStorageAirflowBase(t *testing.T) { 28 | key := types.NamespacedName{ 29 | Name: "foo", 30 | Namespace: "default", 31 | } 32 | created := &AirflowBase{ 33 | ObjectMeta: metav1.ObjectMeta{ 34 | Name: "foo", 35 | Namespace: "default", 36 | }} 37 | g := gomega.NewGomegaWithT(t) 38 | 39 | // Test Create 40 | fetched := &AirflowBase{} 41 | g.Expect(c.Create(context.TODO(), created)).NotTo(gomega.HaveOccurred()) 42 | 43 | g.Expect(c.Get(context.TODO(), key, fetched)).NotTo(gomega.HaveOccurred()) 44 | g.Expect(fetched).To(gomega.Equal(created)) 45 | 46 | // Test Updating the Labels 47 | updated := fetched.DeepCopy() 48 | updated.Labels = map[string]string{"hello": "world"} 49 | g.Expect(c.Update(context.TODO(), updated)).NotTo(gomega.HaveOccurred()) 50 | 51 | g.Expect(c.Get(context.TODO(), key, fetched)).NotTo(gomega.HaveOccurred()) 52 | g.Expect(fetched).To(gomega.Equal(updated)) 53 | 54 | // Test Delete 55 | g.Expect(c.Delete(context.TODO(), fetched)).NotTo(gomega.HaveOccurred()) 56 | g.Expect(c.Get(context.TODO(), key, fetched)).To(gomega.HaveOccurred()) 57 | } 58 | -------------------------------------------------------------------------------- /pkg/apis/airflow/v1alpha1/airflowcluster_types_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package v1alpha1 17 | 18 | import ( 19 | "testing" 20 | 21 | "github.com/onsi/gomega" 22 | "golang.org/x/net/context" 23 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 | "k8s.io/apimachinery/pkg/types" 25 | ) 26 | 27 | func TestStorageAirflowCluster(t *testing.T) { 28 | key := types.NamespacedName{ 29 | Name: "foo", 30 | Namespace: "default", 31 | } 32 | created := &AirflowCluster{ 33 | ObjectMeta: metav1.ObjectMeta{ 34 | Name: "foo", 35 | Namespace: "default", 36 | }} 37 | g := gomega.NewGomegaWithT(t) 38 | 39 | // Test Create 40 | fetched := &AirflowCluster{} 41 | g.Expect(c.Create(context.TODO(), created)).NotTo(gomega.HaveOccurred()) 42 | 43 | g.Expect(c.Get(context.TODO(), key, fetched)).NotTo(gomega.HaveOccurred()) 44 | g.Expect(fetched).To(gomega.Equal(created)) 45 | 46 | // Test Updating the Labels 47 | updated := fetched.DeepCopy() 48 | updated.Labels = map[string]string{"hello": "world"} 49 | g.Expect(c.Update(context.TODO(), updated)).NotTo(gomega.HaveOccurred()) 50 | 51 | g.Expect(c.Get(context.TODO(), key, fetched)).NotTo(gomega.HaveOccurred()) 52 | g.Expect(fetched).To(gomega.Equal(updated)) 53 | 54 | // Test Delete 55 | g.Expect(c.Delete(context.TODO(), fetched)).NotTo(gomega.HaveOccurred()) 56 | g.Expect(c.Get(context.TODO(), key, fetched)).To(gomega.HaveOccurred()) 57 | } 58 | -------------------------------------------------------------------------------- /pkg/apis/airflow/v1alpha1/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package v1alpha1 contains API Schema definitions for the airflow v1alpha1 API group 17 | // +k8s:openapi-gen=true 18 | // +k8s:deepcopy-gen=package,register 19 | // +k8s:conversion-gen=k8s.io/airflow-operator/pkg/apis/airflow 20 | // +k8s:defaulter-gen=TypeMeta 21 | // +groupName=airflow.k8s.io 22 | package v1alpha1 23 | -------------------------------------------------------------------------------- /pkg/apis/airflow/v1alpha1/register.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // NOTE: Boilerplate only. Ignore this file. 17 | 18 | // Package v1alpha1 contains API Schema definitions for the airflow v1alpha1 API group 19 | // +k8s:openapi-gen=true 20 | // +k8s:deepcopy-gen=package,register 21 | // +k8s:conversion-gen=k8s.io/airflow-operator/pkg/apis/airflow 22 | // +k8s:defaulter-gen=TypeMeta 23 | // +groupName=airflow.k8s.io 24 | package v1alpha1 25 | 26 | import ( 27 | "k8s.io/apimachinery/pkg/runtime/schema" 28 | "sigs.k8s.io/controller-runtime/pkg/runtime/scheme" 29 | ) 30 | 31 | var ( 32 | // SchemeGroupVersion is group version used to register these objects 33 | SchemeGroupVersion = schema.GroupVersion{Group: "airflow.k8s.io", Version: "v1alpha1"} 34 | 35 | // SchemeBuilder is used to add go types to the GroupVersionKind scheme 36 | SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} 37 | 38 | // AddToScheme is required by pkg/client/... 39 | AddToScheme = SchemeBuilder.AddToScheme 40 | ) 41 | 42 | // Resource is required by pkg/client/listers/... 43 | func Resource(resource string) schema.GroupResource { 44 | return SchemeGroupVersion.WithResource(resource).GroupResource() 45 | } 46 | -------------------------------------------------------------------------------- /pkg/apis/airflow/v1alpha1/v1alpha1_suite_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package v1alpha1 17 | 18 | import ( 19 | "log" 20 | "os" 21 | "path/filepath" 22 | "testing" 23 | 24 | "k8s.io/client-go/kubernetes/scheme" 25 | "k8s.io/client-go/rest" 26 | "sigs.k8s.io/controller-runtime/pkg/client" 27 | "sigs.k8s.io/controller-runtime/pkg/envtest" 28 | ) 29 | 30 | var cfg *rest.Config 31 | var c client.Client 32 | 33 | func TestMain(m *testing.M) { 34 | t := &envtest.Environment{ 35 | CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "..", "config", "crds")}, 36 | } 37 | 38 | err := SchemeBuilder.AddToScheme(scheme.Scheme) 39 | if err != nil { 40 | log.Fatal(err) 41 | } 42 | 43 | if cfg, err = t.Start(); err != nil { 44 | log.Fatal(err) 45 | } 46 | 47 | if c, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}); err != nil { 48 | log.Fatal(err) 49 | } 50 | 51 | code := m.Run() 52 | t.Stop() 53 | os.Exit(code) 54 | } 55 | -------------------------------------------------------------------------------- /pkg/apis/apis.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Generate deepcopy for apis 17 | //go:generate go run ../../vendor/k8s.io/code-generator/cmd/deepcopy-gen/main.go -O zz_generated.deepcopy -i ./... -h ../../hack/boilerplate.go.txt 18 | 19 | // Package apis contains Kubernetes API groups. 20 | package apis 21 | 22 | import ( 23 | "k8s.io/apimachinery/pkg/runtime" 24 | ) 25 | 26 | // AddToSchemes may be used to add all resources defined in the project to a Scheme 27 | var AddToSchemes runtime.SchemeBuilder 28 | 29 | // AddToScheme adds all Resources to the Scheme 30 | func AddToScheme(s *runtime.Scheme) error { 31 | return AddToSchemes.AddToScheme(s) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/controller/add_airflowbase.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package controller 17 | 18 | import ( 19 | "k8s.io/airflow-operator/pkg/controller/airflowbase" 20 | ) 21 | 22 | func init() { 23 | // AddToManagerFuncs is a list of functions to create controllers and add them to a manager. 24 | AddToManagerFuncs = append(AddToManagerFuncs, airflowbase.Add) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/controller/add_airflowcluster.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package controller 17 | 18 | import ( 19 | "k8s.io/airflow-operator/pkg/controller/airflowcluster" 20 | ) 21 | 22 | func init() { 23 | // AddToManagerFuncs is a list of functions to create controllers and add them to a manager. 24 | AddToManagerFuncs = append(AddToManagerFuncs, airflowcluster.Add) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/controller/airflowbase/airflowbase_controller_suite_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package airflowbase 17 | 18 | import ( 19 | "log" 20 | "os" 21 | "path/filepath" 22 | "sync" 23 | "testing" 24 | 25 | "github.com/onsi/gomega" 26 | "k8s.io/airflow-operator/pkg/apis" 27 | "k8s.io/client-go/kubernetes/scheme" 28 | "k8s.io/client-go/rest" 29 | "sigs.k8s.io/controller-runtime/pkg/envtest" 30 | "sigs.k8s.io/controller-runtime/pkg/manager" 31 | "sigs.k8s.io/controller-runtime/pkg/reconcile" 32 | ) 33 | 34 | var cfg *rest.Config 35 | 36 | func TestMain(m *testing.M) { 37 | t := &envtest.Environment{ 38 | CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crds")}, 39 | } 40 | apis.AddToScheme(scheme.Scheme) 41 | 42 | var err error 43 | if cfg, err = t.Start(); err != nil { 44 | log.Fatal(err) 45 | } 46 | 47 | code := m.Run() 48 | t.Stop() 49 | os.Exit(code) 50 | } 51 | 52 | // SetupTestReconcile returns a reconcile.Reconcile implementation that delegates to inner and 53 | // writes the request to requests after Reconcile is finished. 54 | func SetupTestReconcile(inner reconcile.Reconciler) (reconcile.Reconciler, chan reconcile.Request) { 55 | requests := make(chan reconcile.Request) 56 | fn := reconcile.Func(func(req reconcile.Request) (reconcile.Result, error) { 57 | result, err := inner.Reconcile(req) 58 | requests <- req 59 | return result, err 60 | }) 61 | return fn, requests 62 | } 63 | 64 | // StartTestManager adds recFn 65 | func StartTestManager(mgr manager.Manager, g *gomega.GomegaWithT) (chan struct{}, *sync.WaitGroup) { 66 | stop := make(chan struct{}) 67 | wg := &sync.WaitGroup{} 68 | go func() { 69 | wg.Add(1) 70 | g.Expect(mgr.Start(stop)).NotTo(gomega.HaveOccurred()) 71 | wg.Done() 72 | }() 73 | return stop, wg 74 | } 75 | -------------------------------------------------------------------------------- /pkg/controller/airflowbase/airflowbase_controller_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package airflowbase 17 | 18 | import ( 19 | "testing" 20 | "time" 21 | 22 | "github.com/onsi/gomega" 23 | "golang.org/x/net/context" 24 | airflowv1alpha1 "k8s.io/airflow-operator/pkg/apis/airflow/v1alpha1" 25 | appsv1 "k8s.io/api/apps/v1" 26 | apierrors "k8s.io/apimachinery/pkg/api/errors" 27 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 28 | "k8s.io/apimachinery/pkg/types" 29 | "sigs.k8s.io/controller-runtime/pkg/client" 30 | "sigs.k8s.io/controller-runtime/pkg/manager" 31 | "sigs.k8s.io/controller-runtime/pkg/reconcile" 32 | ) 33 | 34 | var c client.Client 35 | 36 | var expectedRequest = reconcile.Request{NamespacedName: types.NamespacedName{Name: "foo", Namespace: "default"}} 37 | var mysqlkey = types.NamespacedName{Name: "foo-mysql", Namespace: "default"} 38 | var nfskey = types.NamespacedName{Name: "foo-nfs", Namespace: "default"} 39 | 40 | const timeout = time.Second * 5 41 | 42 | func TestReconcile(t *testing.T) { 43 | g := gomega.NewGomegaWithT(t) 44 | instance := &airflowv1alpha1.AirflowBase{ 45 | ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "default"}, 46 | Spec: airflowv1alpha1.AirflowBaseSpec{ 47 | MySQL: &airflowv1alpha1.MySQLSpec{ 48 | Operator: false, 49 | }, 50 | Storage: &airflowv1alpha1.NFSStoreSpec{ 51 | Version: "", 52 | }, 53 | }, 54 | } 55 | 56 | // Setup the Manager and Controller. Wrap the Controller Reconcile function so it writes each request to a 57 | // channel when it is finished. 58 | mgr, err := manager.New(cfg, manager.Options{}) 59 | g.Expect(err).NotTo(gomega.HaveOccurred()) 60 | c = mgr.GetClient() 61 | 62 | r := newReconciler(mgr) 63 | recFn, requests := SetupTestReconcile(r) 64 | g.Expect(r.Controller(recFn)).NotTo(gomega.HaveOccurred()) 65 | 66 | stopMgr, mgrStopped := StartTestManager(mgr, g) 67 | 68 | defer func() { 69 | close(stopMgr) 70 | mgrStopped.Wait() 71 | }() 72 | 73 | // Create the AirflowBase object and expect the Reconcile and Deployment to be created 74 | err = c.Create(context.TODO(), instance) 75 | // The instance object may not be a valid object because it might be missing some required fields. 76 | // Please modify the instance object by adding required fields and then remove the following if statement. 77 | if apierrors.IsInvalid(err) { 78 | t.Logf("failed to create object, got an invalid object error: %v", err) 79 | return 80 | } 81 | g.Expect(err).NotTo(gomega.HaveOccurred()) 82 | defer c.Delete(context.TODO(), instance) 83 | g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedRequest))) 84 | 85 | mysqlsts := &appsv1.StatefulSet{} 86 | nfssts := &appsv1.StatefulSet{} 87 | g.Eventually(func() error { return c.Get(context.TODO(), mysqlkey, mysqlsts) }, timeout).Should(gomega.Succeed()) 88 | g.Eventually(func() error { return c.Get(context.TODO(), nfskey, nfssts) }, timeout).Should(gomega.Succeed()) 89 | 90 | // Delete the Deployment and expect Reconcile to be called for Deployment deletion 91 | g.Expect(c.Delete(context.TODO(), mysqlsts)).NotTo(gomega.HaveOccurred()) 92 | g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedRequest))) 93 | g.Eventually(func() error { return c.Get(context.TODO(), mysqlkey, mysqlsts) }, timeout).Should(gomega.Succeed()) 94 | 95 | // Manually delete Deployment since GC isn't enabled in the test control plane 96 | g.Expect(c.Delete(context.TODO(), nfssts)).To(gomega.Succeed()) 97 | 98 | } 99 | -------------------------------------------------------------------------------- /pkg/controller/airflowcluster/airflowcluster_controller_suite_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package airflowcluster 17 | 18 | import ( 19 | "log" 20 | "os" 21 | "path/filepath" 22 | "sync" 23 | "testing" 24 | 25 | "github.com/onsi/gomega" 26 | "k8s.io/airflow-operator/pkg/apis" 27 | "k8s.io/client-go/kubernetes/scheme" 28 | "k8s.io/client-go/rest" 29 | "sigs.k8s.io/controller-runtime/pkg/envtest" 30 | "sigs.k8s.io/controller-runtime/pkg/manager" 31 | "sigs.k8s.io/controller-runtime/pkg/reconcile" 32 | ) 33 | 34 | var cfg *rest.Config 35 | 36 | func TestMain(m *testing.M) { 37 | t := &envtest.Environment{ 38 | CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crds")}, 39 | } 40 | apis.AddToScheme(scheme.Scheme) 41 | 42 | var err error 43 | if cfg, err = t.Start(); err != nil { 44 | log.Fatal(err) 45 | } 46 | 47 | code := m.Run() 48 | t.Stop() 49 | os.Exit(code) 50 | } 51 | 52 | // SetupTestReconcile returns a reconcile.Reconcile implementation that delegates to inner and 53 | // writes the request to requests after Reconcile is finished. 54 | func SetupTestReconcile(inner reconcile.Reconciler) (reconcile.Reconciler, chan reconcile.Request) { 55 | requests := make(chan reconcile.Request) 56 | fn := reconcile.Func(func(req reconcile.Request) (reconcile.Result, error) { 57 | result, err := inner.Reconcile(req) 58 | requests <- req 59 | return result, err 60 | }) 61 | return fn, requests 62 | } 63 | 64 | // StartTestManager adds recFn 65 | func StartTestManager(mgr manager.Manager, g *gomega.GomegaWithT) (chan struct{}, *sync.WaitGroup) { 66 | stop := make(chan struct{}) 67 | wg := &sync.WaitGroup{} 68 | go func() { 69 | wg.Add(1) 70 | g.Expect(mgr.Start(stop)).NotTo(gomega.HaveOccurred()) 71 | wg.Done() 72 | }() 73 | return stop, wg 74 | } 75 | -------------------------------------------------------------------------------- /pkg/controller/application/application.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package application 17 | 18 | import ( 19 | app "github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1" 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | "sigs.k8s.io/controller-reconciler/pkg/reconciler" 24 | "sigs.k8s.io/controller-reconciler/pkg/reconciler/manager/k8s" 25 | ) 26 | 27 | // Application obj to attach methods 28 | type Application struct { 29 | *app.Application 30 | } 31 | 32 | // NewApplication - return Application object from runtime Object 33 | func NewApplication(obj metav1.Object) Application { 34 | return Application{obj.(*app.Application)} 35 | } 36 | 37 | // SetSelector attaches selectors to Application object 38 | func (a *Application) SetSelector(labels map[string]string) *Application { 39 | a.Spec.Selector = &metav1.LabelSelector{MatchLabels: labels} 40 | return a 41 | } 42 | 43 | // SetName sets name 44 | func (a *Application) SetName(value string) *Application { 45 | a.ObjectMeta.Name = value 46 | return a 47 | } 48 | 49 | // SetNamespace asets namespace 50 | func (a *Application) SetNamespace(value string) *Application { 51 | a.ObjectMeta.Namespace = value 52 | return a 53 | } 54 | 55 | // AddLabels adds more labels 56 | func (a *Application) AddLabels(value reconciler.KVMap) *Application { 57 | value.Merge(a.ObjectMeta.Labels) 58 | a.ObjectMeta.Labels = value 59 | return a 60 | } 61 | 62 | // Observable returns resource object 63 | func (a *Application) Observable() *reconciler.Observable { 64 | return &reconciler.Observable{ 65 | Obj: k8s.Observable{ 66 | Obj: a.Application, 67 | ObjList: &app.ApplicationList{}, 68 | Labels: a.GetLabels(), 69 | }, 70 | Type: k8s.Type, 71 | } 72 | } 73 | 74 | // Item returns resource object 75 | func (a *Application) Item() *reconciler.Object { 76 | return &reconciler.Object{ 77 | Lifecycle: reconciler.LifecycleManaged, 78 | Type: k8s.Type, 79 | Obj: &k8s.Object{ 80 | Obj: a.Application, 81 | ObjList: &app.ApplicationList{}, 82 | }, 83 | } 84 | } 85 | 86 | // AddToScheme return AddToScheme of application crd 87 | func AddToScheme(sb *runtime.SchemeBuilder) { 88 | *sb = append(*sb, app.AddToScheme) 89 | } 90 | 91 | // SetComponentGK attaches component GK to Application object 92 | func (a *Application) SetComponentGK(bag []reconciler.Object) *Application { 93 | a.Spec.ComponentGroupKinds = []metav1.GroupKind{} 94 | gkmap := map[schema.GroupKind]struct{}{} 95 | for _, item := range reconciler.ObjectsByType(bag, k8s.Type) { 96 | obj := item.Obj.(*k8s.Object) 97 | if obj.ObjList != nil { 98 | ro := obj.Obj.(runtime.Object) 99 | gk := ro.GetObjectKind().GroupVersionKind().GroupKind() 100 | if _, ok := gkmap[gk]; !ok { 101 | gkmap[gk] = struct{}{} 102 | mgk := metav1.GroupKind{ 103 | Group: gk.Group, 104 | Kind: gk.Kind, 105 | } 106 | a.Spec.ComponentGroupKinds = append(a.Spec.ComponentGroupKinds, mgk) 107 | } 108 | } 109 | } 110 | return a 111 | } 112 | -------------------------------------------------------------------------------- /pkg/controller/application/application_suite_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package application_test 17 | 18 | import ( 19 | . "github.com/onsi/ginkgo" 20 | . "github.com/onsi/gomega" 21 | "testing" 22 | ) 23 | 24 | // TestEventhandler exports tests 25 | func TestEventhandler(t *testing.T) { 26 | RegisterFailHandler(Fail) 27 | RunSpecsWithDefaultAndCustomReporters(t, "Application Suite", []Reporter{}) 28 | } 29 | -------------------------------------------------------------------------------- /pkg/controller/application/application_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package application_test 17 | 18 | import ( 19 | app "github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1" 20 | . "github.com/onsi/ginkgo" 21 | . "github.com/onsi/gomega" 22 | "k8s.io/airflow-operator/pkg/controller/application" 23 | appsv1 "k8s.io/api/apps/v1" 24 | corev1 "k8s.io/api/core/v1" 25 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | "sigs.k8s.io/controller-reconciler/pkg/reconciler" 27 | "sigs.k8s.io/controller-reconciler/pkg/reconciler/manager/k8s" 28 | ) 29 | 30 | var _ = Describe("Application", func() { 31 | BeforeEach(func() { 32 | }) 33 | labels := map[string]string{ 34 | "k1": "v1", 35 | "k2": "v2", 36 | "k3": "v3", 37 | } 38 | var resources []reconciler.Object = []reconciler.Object{ 39 | { 40 | Lifecycle: reconciler.LifecycleManaged, 41 | Type: k8s.Type, 42 | Obj: &k8s.Object{ 43 | ObjList: &appsv1.DeploymentList{}, 44 | Obj: &appsv1.Deployment{ 45 | TypeMeta: metav1.TypeMeta{ 46 | Kind: "k3", 47 | APIVersion: "v4", 48 | }, 49 | ObjectMeta: metav1.ObjectMeta{ 50 | Name: "n-deploy", 51 | Namespace: "ns", 52 | Labels: labels, 53 | }, 54 | }, 55 | }, 56 | }, 57 | { 58 | Lifecycle: reconciler.LifecycleManaged, 59 | Type: k8s.Type, 60 | Obj: &k8s.Object{ 61 | ObjList: &corev1.ConfigMapList{}, 62 | Obj: &corev1.ConfigMap{ 63 | TypeMeta: metav1.TypeMeta{ 64 | Kind: "k1", 65 | APIVersion: "v2", 66 | }, 67 | ObjectMeta: metav1.ObjectMeta{ 68 | Name: "n-cm", 69 | Namespace: "ns", 70 | Labels: labels, 71 | }, 72 | Data: map[string]string{ 73 | "test-key": "test-value", 74 | }, 75 | }, 76 | }, 77 | }, 78 | } 79 | a := application.NewApplication(&app.Application{}) 80 | Describe("Status", func() { 81 | It("Sets Component Group Kind", func(done Done) { 82 | a.SetComponentGK(resources) 83 | Expect(len(a.Spec.ComponentGroupKinds)).To(Equal(len(resources))) 84 | close(done) 85 | }) 86 | It("Sets Selector", func(done Done) { 87 | a.SetSelector(labels) 88 | Expect(a.Spec.Selector.MatchLabels).To(Equal(labels)) 89 | close(done) 90 | }) 91 | It("Sets Meta Name Namespace Labels", func(done Done) { 92 | a.SetName("somename").SetNamespace("somens").SetLabels(labels) 93 | Expect(a.ObjectMeta.Name).To(Equal("somename")) 94 | Expect(a.ObjectMeta.Namespace).To(Equal("somens")) 95 | Expect(a.ObjectMeta.Labels).To(Equal(labels)) 96 | close(done) 97 | }) 98 | }) 99 | }) 100 | -------------------------------------------------------------------------------- /pkg/controller/application/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package application contains code for creating appcrd 17 | 18 | package application 19 | -------------------------------------------------------------------------------- /pkg/controller/common/common.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package common 17 | 18 | import ( 19 | "bytes" 20 | "fmt" 21 | alpha1 "k8s.io/airflow-operator/pkg/apis/airflow/v1alpha1" 22 | corev1 "k8s.io/api/core/v1" 23 | "math/rand" 24 | "sigs.k8s.io/controller-reconciler/pkg/reconciler" 25 | "sigs.k8s.io/controller-reconciler/pkg/reconciler/manager/k8s" 26 | "time" 27 | ) 28 | 29 | // Constants 30 | const ( 31 | PasswordCharNumSpace = "abcdefghijklmnopqrstuvwxyz0123456789" 32 | PasswordCharSpace = "abcdefghijklmnopqrstuvwxyz" 33 | 34 | LabelAirflowCR = "airflow-cr" 35 | ValueAirflowCRBase = "airflow-base" 36 | ValueAirflowCRCluster = "airflow-cluster" 37 | LabelAirflowCRName = "airflow-cr-name" 38 | LabelAirflowComponent = "airflow-component" 39 | ValueAirflowComponentMemoryStore = "redis" 40 | ValueAirflowComponentMySQL = "mysql" 41 | ValueAirflowComponentPostgres = "postgres" 42 | ValueAirflowComponentSQLProxy = "sqlproxy" 43 | ValueAirflowComponentBase = "base" 44 | ValueAirflowComponentCluster = "cluster" 45 | ValueAirflowComponentSQL = "sql" 46 | ValueAirflowComponentUI = "airflowui" 47 | ValueAirflowComponentNFS = "nfs" 48 | ValueAirflowComponentRedis = "redis" 49 | ValueAirflowComponentScheduler = "scheduler" 50 | ValueAirflowComponentWorker = "worker" 51 | ValueAirflowComponentFlower = "flower" 52 | ValueSQLProxyTypeMySQL = "mysql" 53 | ValueSQLProxyTypePostgres = "postgres" 54 | LabelApp = "app" 55 | 56 | KindAirflowBase = "AirflowBase" 57 | KindAirflowCluster = "AirflowCluster" 58 | 59 | PodManagementPolicyParallel = "Parallel" 60 | 61 | TemplatePath = "templates/" 62 | ) 63 | 64 | var ( 65 | random = rand.New(rand.NewSource(time.Now().UnixNano())) 66 | ) 67 | 68 | func optionsToString(options map[string]string, prefix string) string { 69 | var buf bytes.Buffer 70 | for k, v := range options { 71 | buf.WriteString(fmt.Sprintf("%s%s %s ", prefix, k, v)) 72 | } 73 | return buf.String() 74 | } 75 | 76 | // RandomAlphanumericString generates a random password of some fixed length. 77 | func RandomAlphanumericString(strlen int) []byte { 78 | result := make([]byte, strlen) 79 | for i := range result { 80 | result[i] = PasswordCharNumSpace[random.Intn(len(PasswordCharNumSpace))] 81 | } 82 | result[0] = PasswordCharSpace[random.Intn(len(PasswordCharSpace))] 83 | return result 84 | } 85 | 86 | // RsrcName - create name 87 | func RsrcName(name string, component string, suffix string) string { 88 | return name + "-" + component + suffix 89 | } 90 | 91 | // TemplateValue replacer 92 | type TemplateValue struct { 93 | Name string 94 | Namespace string 95 | SecretName string 96 | SvcName string 97 | Base *alpha1.AirflowBase 98 | Cluster *alpha1.AirflowCluster 99 | Labels reconciler.KVMap 100 | Selector reconciler.KVMap 101 | Ports map[string]string 102 | Secret map[string]string 103 | PDBMinAvail string 104 | Expected []reconciler.Object 105 | SQLConn string 106 | } 107 | 108 | // differs returns true if the resource needs to be updated 109 | func differs(expected reconciler.Object, observed reconciler.Object) bool { 110 | switch expected.Obj.(*k8s.Object).Obj.(type) { 111 | case *corev1.ServiceAccount: 112 | // Dont update a SA 113 | return false 114 | case *corev1.Secret: 115 | // Dont update a secret 116 | return false 117 | } 118 | return true 119 | } 120 | -------------------------------------------------------------------------------- /pkg/controller/controller.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package controller 17 | 18 | import ( 19 | "sigs.k8s.io/controller-runtime/pkg/manager" 20 | ) 21 | 22 | // AddToManagerFuncs is a list of functions to add all Controllers to the Manager 23 | var AddToManagerFuncs []func(manager.Manager) error 24 | 25 | // AddToManager adds all Controllers to the Manager 26 | func AddToManager(m manager.Manager) error { 27 | for _, f := range AddToManagerFuncs { 28 | if err := f(m); err != nil { 29 | return err 30 | } 31 | } 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /pkg/webhook/webhook.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package webhook 17 | 18 | import ( 19 | "sigs.k8s.io/controller-runtime/pkg/manager" 20 | ) 21 | 22 | // AddToManagerFuncs is a list of functions to add all Controllers to the Manager 23 | var AddToManagerFuncs []func(manager.Manager) error 24 | 25 | // AddToManager adds all Controllers to the Manager 26 | // +kubebuilder:rbac:groups=admissionregistration.k8s.io,resources=mutatingwebhookconfigurations;validatingwebhookconfigurations,verbs=get;list;watch;create;update;patch;delete 27 | // +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;update;patch;delete 28 | // +kubebuilder:rbac:groups="",resources=services,verbs=get;list;watch;create;update;patch;delete 29 | func AddToManager(m manager.Manager) error { 30 | for _, f := range AddToManagerFuncs { 31 | if err := f(m); err != nil { 32 | return err 33 | } 34 | } 35 | return nil 36 | } 37 | -------------------------------------------------------------------------------- /templates/flower-sts.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: apps/v1 18 | kind: StatefulSet 19 | metadata: 20 | name: {{.Name}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | annotations: 27 | {{range $k,$v := .Cluster.Spec.Annotations }} 28 | {{$k}}: {{$v}} 29 | {{end}} 30 | spec: 31 | replicas: {{.Cluster.Spec.Flower.Replicas}} 32 | selector: 33 | matchLabels: 34 | {{range $k,$v := .Selector }} 35 | {{$k}}: {{$v}} 36 | {{end}} 37 | updateStrategy: 38 | type: RollingUpdate 39 | podManagementPolicy: Parallel 40 | template: 41 | metadata: 42 | labels: 43 | {{range $k,$v := .Labels }} 44 | {{$k}}: {{$v}} 45 | {{end}} 46 | annotations: 47 | {{range $k,$v := .Cluster.Spec.Annotations }} 48 | {{$k}}: {{$v}} 49 | {{end}} 50 | spec: 51 | terminationGracePeriodSeconds: 30 52 | nodeSelector: 53 | {{range $k,$v := .Cluster.Spec.NodeSelector }} 54 | {{$k}}: {{$v}} 55 | {{end}} 56 | containers: 57 | - name: flower 58 | args: 59 | - flower 60 | image: {{.Cluster.Spec.Flower.Image}}:{{.Cluster.Spec.Flower.Version}} 61 | imagePullPolicy: IfNotPresent 62 | ports: 63 | - containerPort: 5555 64 | name: flower 65 | volumeMounts: 66 | - mountPath: /usr/local/airflow/dags/ 67 | name: dags-data 68 | volumes: 69 | - emptyDir: {} 70 | name: dags-data 71 | -------------------------------------------------------------------------------- /templates/headlesssvc.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: v1 18 | kind: Service 19 | metadata: 20 | name: {{.SvcName}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | spec: 27 | ports: 28 | {{range $k,$v := .Ports }} 29 | - name: {{$k}} 30 | port: {{$v}} 31 | {{end}} 32 | selector: 33 | {{range $k,$v := .Selector }} 34 | {{$k}}: {{$v}} 35 | {{end}} 36 | clusterIP: None 37 | -------------------------------------------------------------------------------- /templates/mysql-sts.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: apps/v1 18 | kind: StatefulSet 19 | metadata: 20 | name: {{.Name}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | annotations: 27 | {{range $k,$v := .Base.Spec.Annotations }} 28 | {{$k}}: {{$v}} 29 | {{end}} 30 | spec: 31 | replicas: {{.Base.Spec.MySQL.Replicas}} 32 | selector: 33 | matchLabels: 34 | {{range $k,$v := .Selector }} 35 | {{$k}}: {{$v}} 36 | {{end}} 37 | updateStrategy: 38 | type: OnDelete 39 | podManagementPolicy: OrderedReady 40 | template: 41 | metadata: 42 | labels: 43 | {{range $k,$v := .Labels }} 44 | {{$k}}: {{$v}} 45 | {{end}} 46 | annotations: 47 | {{range $k,$v := .Base.Spec.Annotations }} 48 | {{$k}}: {{$v}} 49 | {{end}} 50 | spec: 51 | ## TODO affinity in code 52 | terminationGracePeriodSeconds: 30 ## check this change to 180 ? 53 | #priorityClassName: something 54 | #securityContext: 55 | # fsGroup: 1000 56 | nodeSelector: 57 | {{range $k,$v := .Base.Spec.NodeSelector }} 58 | {{$k}}: {{$v}} 59 | {{end}} 60 | #tolerations: 61 | #initContainers: 62 | containers: 63 | - name: mysql 64 | args: 65 | - --explicit-defaults-for-timestamp=ON 66 | env: 67 | - name: MYSQL_DATABASE 68 | value: testdb 69 | - name: MYSQL_USER 70 | value: airflow 71 | - name: MYSQL_PASSWORD 72 | valueFrom: 73 | secretKeyRef: 74 | key: password 75 | name: {{.SecretName}} 76 | - name: MYSQL_ROOT_PASSWORD 77 | valueFrom: 78 | secretKeyRef: 79 | key: rootpassword 80 | name: {{.SecretName}} 81 | image: {{.Base.Spec.MySQL.Image}}:{{.Base.Spec.MySQL.Version}} 82 | imagePullPolicy: IfNotPresent 83 | livenessProbe: 84 | exec: 85 | command: 86 | - bash 87 | - -c 88 | - mysqladmin -p$MYSQL_ROOT_PASSWORD ping 89 | failureThreshold: 3 90 | initialDelaySeconds: 30 91 | periodSeconds: 20 92 | successThreshold: 1 93 | timeoutSeconds: 5 94 | ports: 95 | - containerPort: 3306 96 | name: mysql 97 | protocol: TCP 98 | readinessProbe: 99 | exec: 100 | command: 101 | - bash 102 | - -c 103 | - mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e "use testdb" 104 | failureThreshold: 3 105 | initialDelaySeconds: 10 106 | periodSeconds: 5 107 | successThreshold: 1 108 | timeoutSeconds: 2 109 | resources: {} 110 | volumeMounts: 111 | - name: data 112 | mountPath: /var/lib/mysql 113 | restartPolicy: Always 114 | {{if .Base.Spec.MySQL.VolumeClaimTemplate}} 115 | {{else}} 116 | volumes: 117 | - emptyDir: {} 118 | name: data 119 | {{end}} 120 | -------------------------------------------------------------------------------- /templates/nfs-sts.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: apps/v1 18 | kind: StatefulSet 19 | metadata: 20 | name: {{.Name}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | annotations: 27 | {{range $k,$v := .Base.Spec.Annotations }} 28 | {{$k}}: {{$v}} 29 | {{end}} 30 | spec: 31 | replicas: 1 32 | selector: 33 | matchLabels: 34 | {{range $k,$v := .Selector }} 35 | {{$k}}: {{$v}} 36 | {{end}} 37 | updateStrategy: 38 | type: OnDelete 39 | podManagementPolicy: Parallel 40 | serviceName: {{.SvcName}} 41 | template: 42 | metadata: 43 | labels: 44 | {{range $k,$v := .Labels }} 45 | {{$k}}: {{$v}} 46 | {{end}} 47 | annotations: 48 | {{range $k,$v := .Base.Spec.Annotations }} 49 | {{$k}}: {{$v}} 50 | {{end}} 51 | spec: 52 | terminationGracePeriodSeconds: 30 ## check this change to 180 ? 53 | nodeSelector: 54 | {{range $k,$v := .Base.Spec.NodeSelector }} 55 | {{$k}}: {{$v}} 56 | {{end}} 57 | containers: 58 | - name: nfs-server 59 | image: {{.Base.Spec.Storage.Image}}:{{.Base.Spec.Storage.Version}} 60 | imagePullPolicy: IfNotPresent 61 | ports: 62 | - containerPort: 2049 63 | name: nfs 64 | protocol: TCP 65 | - containerPort: 20048 66 | name: mountd 67 | protocol: TCP 68 | - containerPort: 111 69 | name: rpcbind 70 | protocol: TCP 71 | resources: {} 72 | volumeMounts: 73 | - mountPath: /exports 74 | name: data 75 | restartPolicy: Always 76 | {{if .Base.Spec.Storage.Volume}} 77 | {{else}} 78 | volumes: 79 | - emptyDir: {} 80 | name: data 81 | {{end}} 82 | -------------------------------------------------------------------------------- /templates/pdb.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: policy/v1beta1 18 | kind: PodDisruptionBudget 19 | metadata: 20 | name: {{.Name}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | spec: 27 | minAvailable: {{.PDBMinAvail}} 28 | selector: 29 | matchLabels: 30 | {{range $k,$v := .Selector }} 31 | {{$k}}: {{$v}} 32 | {{end}} 33 | -------------------------------------------------------------------------------- /templates/postgres-sts.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: apps/v1 18 | kind: StatefulSet 19 | metadata: 20 | name: {{.Name}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | annotations: 27 | {{range $k,$v := .Base.Spec.Annotations }} 28 | {{$k}}: {{$v}} 29 | {{end}} 30 | spec: 31 | replicas: {{.Base.Spec.Postgres.Replicas}} 32 | selector: 33 | matchLabels: 34 | {{range $k,$v := .Selector }} 35 | {{$k}}: {{$v}} 36 | {{end}} 37 | updateStrategy: 38 | type: OnDelete 39 | podManagementPolicy: OrderedReady 40 | template: 41 | metadata: 42 | labels: 43 | {{range $k,$v := .Labels }} 44 | {{$k}}: {{$v}} 45 | {{end}} 46 | annotations: 47 | {{range $k,$v := .Base.Spec.Annotations }} 48 | {{$k}}: {{$v}} 49 | {{end}} 50 | spec: 51 | terminationGracePeriodSeconds: 30 52 | nodeSelector: 53 | {{range $k,$v := .Base.Spec.NodeSelector }} 54 | {{$k}}: {{$v}} 55 | {{end}} 56 | containers: 57 | - name: postgres 58 | env: 59 | - name: POSTGRES_DB 60 | value: testdb 61 | - name: POSTGRES_USER 62 | value: postgres 63 | - name: POSTGRES_PASSWORD 64 | valueFrom: 65 | secretKeyRef: 66 | key: rootpassword 67 | name: {{.SecretName}} 68 | image: {{.Base.Spec.Postgres.Image}}:{{.Base.Spec.Postgres.Version}} 69 | imagePullPolicy: IfNotPresent 70 | livenessProbe: 71 | exec: 72 | command: 73 | - bash 74 | - -c 75 | - psql -w -U $POSTGRES_USER -d $POSTGRES_DB -c SELECT 1 76 | failureThreshold: 3 77 | initialDelaySeconds: 30 78 | periodSeconds: 20 79 | successThreshold: 1 80 | timeoutSeconds: 5 81 | ports: 82 | - containerPort: 5432 83 | name: postgres 84 | readinessProbe: 85 | exec: 86 | command: 87 | - bash 88 | - -c 89 | - psql -w -U $POSTGRES_USER -d $POSTGRES_DB -c SELECT 1 90 | failureThreshold: 3 91 | initialDelaySeconds: 10 92 | periodSeconds: 5 93 | successThreshold: 1 94 | timeoutSeconds: 2 95 | volumeMounts: 96 | - name: data 97 | mountPath: /var/lib/postgres/data 98 | restartPolicy: Always 99 | {{if .Base.Spec.Postgres.VolumeClaimTemplate}} 100 | {{else}} 101 | volumes: 102 | - emptyDir: {} 103 | name: data 104 | {{end}} 105 | -------------------------------------------------------------------------------- /templates/redis-sts.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: apps/v1 18 | kind: StatefulSet 19 | metadata: 20 | name: {{.Name}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | annotations: 27 | {{range $k,$v := .Cluster.Spec.Annotations }} 28 | {{$k}}: {{$v}} 29 | {{end}} 30 | spec: 31 | replicas: 1 32 | selector: 33 | matchLabels: 34 | {{range $k,$v := .Selector }} 35 | {{$k}}: {{$v}} 36 | {{end}} 37 | updateStrategy: 38 | type: OnDelete 39 | podManagementPolicy: OrderedReady 40 | template: 41 | metadata: 42 | labels: 43 | {{range $k,$v := .Labels }} 44 | {{$k}}: {{$v}} 45 | {{end}} 46 | annotations: 47 | {{range $k,$v := .Cluster.Spec.Annotations }} 48 | {{$k}}: {{$v}} 49 | {{end}} 50 | spec: 51 | terminationGracePeriodSeconds: 30 52 | nodeSelector: 53 | {{range $k,$v := .Cluster.Spec.NodeSelector }} 54 | {{$k}}: {{$v}} 55 | {{end}} 56 | containers: 57 | - name: redis 58 | args: 59 | - --requirepass 60 | - $(REDIS_PASSWORD) 61 | {{if .Cluster.Spec.Redis.AdditionalArgs}} 62 | - {{.Cluster.Spec.Redis.AdditionalArgs}} 63 | {{end}} 64 | env: 65 | - name: REDIS_EXTRA_FLAGS 66 | - name: REDIS_PASSWORD 67 | valueFrom: 68 | secretKeyRef: 69 | key: password 70 | name: {{.SecretName}} 71 | image: {{.Cluster.Spec.Redis.Image}}:{{.Cluster.Spec.Redis.Version}} 72 | imagePullPolicy: IfNotPresent 73 | livenessProbe: 74 | exec: 75 | command: 76 | - redis-cli 77 | - ping 78 | failureThreshold: 3 79 | initialDelaySeconds: 30 80 | periodSeconds: 20 81 | successThreshold: 1 82 | timeoutSeconds: 5 83 | ports: 84 | - containerPort: 6379 85 | name: redis 86 | protocol: TCP 87 | readinessProbe: 88 | exec: 89 | command: 90 | - redis-cli 91 | - ping 92 | failureThreshold: 3 93 | initialDelaySeconds: 10 94 | periodSeconds: 5 95 | successThreshold: 1 96 | timeoutSeconds: 2 97 | volumeMounts: 98 | - mountPath: /data 99 | name: data 100 | restartPolicy: Always 101 | {{if .Cluster.Spec.Redis.VolumeClaimTemplate}} 102 | {{else}} 103 | volumes: 104 | - emptyDir: {} 105 | name: data 106 | {{end}} 107 | -------------------------------------------------------------------------------- /templates/rolebinding.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: rbac.authorization.k8s.io/v1 18 | kind: RoleBinding 19 | metadata: 20 | name: {{.Name}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | roleRef: 27 | apiGroup: rbac.authorization.k8s.io 28 | kind: ClusterRole 29 | # TODO - restrict this to manager-role with pod creation 30 | name: cluster-admin 31 | subjects: 32 | - kind: ServiceAccount 33 | name: {{.Name}} 34 | namespace: {{.Namespace}} 35 | -------------------------------------------------------------------------------- /templates/scheduler-sts.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: apps/v1 18 | kind: StatefulSet 19 | metadata: 20 | name: {{.Name}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | annotations: 27 | {{range $k,$v := .Cluster.Spec.Annotations }} 28 | {{$k}}: {{$v}} 29 | {{end}} 30 | spec: 31 | replicas: 1 32 | selector: 33 | matchLabels: 34 | {{range $k,$v := .Selector }} 35 | {{$k}}: {{$v}} 36 | {{end}} 37 | updateStrategy: 38 | type: RollingUpdate 39 | podManagementPolicy: Parallel 40 | template: 41 | metadata: 42 | labels: 43 | {{range $k,$v := .Labels }} 44 | {{$k}}: {{$v}} 45 | {{end}} 46 | annotations: 47 | {{range $k,$v := .Cluster.Spec.Annotations }} 48 | {{$k}}: {{$v}} 49 | {{end}} 50 | spec: 51 | terminationGracePeriodSeconds: 30 52 | nodeSelector: 53 | {{range $k,$v := .Cluster.Spec.NodeSelector }} 54 | {{$k}}: {{$v}} 55 | {{end}} 56 | containers: 57 | - name: scheduler 58 | args: 59 | - scheduler 60 | image: {{.Cluster.Spec.Scheduler.Image}}:{{.Cluster.Spec.Scheduler.Version}} 61 | imagePullPolicy: IfNotPresent 62 | volumeMounts: 63 | - mountPath: /usr/local/airflow/dags/ 64 | name: dags-data 65 | - name: metrics 66 | image: pbweb/airflow-prometheus-exporter:latest 67 | imagePullPolicy: IfNotPresent 68 | ports: 69 | - containerPort: 9112 70 | name: metrics 71 | volumes: 72 | - emptyDir: {} 73 | name: dags-data 74 | -------------------------------------------------------------------------------- /templates/secret.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: v1 18 | kind: Secret 19 | metadata: 20 | name: {{.SecretName}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | data: 27 | {{range $k,$v := .Secret }} 28 | {{$k}}: {{$v}} 29 | {{end}} 30 | -------------------------------------------------------------------------------- /templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: v1 18 | kind: ServiceAccount 19 | metadata: 20 | name: {{.Name}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | -------------------------------------------------------------------------------- /templates/sqlproxy-sts.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: apps/v1 18 | kind: StatefulSet 19 | metadata: 20 | name: {{.Name}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | annotations: 27 | {{range $k,$v := .Base.Spec.Annotations }} 28 | {{$k}}: {{$v}} 29 | {{end}} 30 | spec: 31 | replicas: 1 32 | selector: 33 | matchLabels: 34 | {{range $k,$v := .Selector }} 35 | {{$k}}: {{$v}} 36 | {{end}} 37 | updateStrategy: 38 | type: RollingUpdate 39 | podManagementPolicy: OrderedReady 40 | serviceName: {{.SvcName}} 41 | template: 42 | metadata: 43 | labels: 44 | {{range $k,$v := .Labels }} 45 | {{$k}}: {{$v}} 46 | {{end}} 47 | annotations: 48 | {{range $k,$v := .Base.Spec.Annotations }} 49 | {{$k}}: {{$v}} 50 | {{end}} 51 | spec: 52 | ## TODO affinity in code 53 | terminationGracePeriodSeconds: 30 ## check this change to 180 ? 54 | #priorityClassName: something 55 | #securityContext: 56 | # fsGroup: 1000 57 | nodeSelector: 58 | {{range $k,$v := .Base.Spec.NodeSelector }} 59 | {{$k}}: {{$v}} 60 | {{end}} 61 | #tolerations: 62 | #initContainers: 63 | containers: 64 | - name: sqlproxy 65 | command: 66 | - /cloud_sql_proxy 67 | - -instances 68 | - $(SQL_INSTANCE) 69 | env: 70 | - name: SQL_INSTANCE 71 | value: {{.Base.Spec.SQLProxy.Project}}:{{.Base.Spec.SQLProxy.Region}}:{{.Base.Spec.SQLProxy.Instance}}=tcp:0.0.0.0:{{index .Ports "sqlproxy"}} 72 | image: {{.Base.Spec.SQLProxy.Image}}:{{.Base.Spec.SQLProxy.Version}} 73 | imagePullPolicy: IfNotPresent 74 | ports: 75 | - containerPort: {{index .Ports "sqlproxy"}} 76 | name: sqlproxy 77 | protocol: TCP 78 | resources: {} 79 | -------------------------------------------------------------------------------- /templates/storage.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | kind: StorageClass 18 | apiVersion: storage.k8s.io/v1 19 | metadata: 20 | name: ssd 21 | labels: 22 | {{range $k,$v := .Labels }} 23 | {{$k}}: {{$v}} 24 | {{end}} 25 | provisioner: kubernetes.io/gce-pd 26 | parameters: 27 | type: pd-ssd 28 | zone: asia-southeast1-a 29 | -------------------------------------------------------------------------------- /templates/svc.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: v1 18 | kind: Service 19 | metadata: 20 | name: {{.SvcName}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | spec: 27 | ports: 28 | {{range $k,$v := .Ports }} 29 | - name: {{$k}} 30 | port: {{$v}} 31 | {{end}} 32 | selector: 33 | {{range $k,$v := .Selector }} 34 | {{$k}}: {{$v}} 35 | {{end}} 36 | type: ClusterIP # default can drop 37 | -------------------------------------------------------------------------------- /templates/ui-sts.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: apps/v1 18 | kind: StatefulSet 19 | metadata: 20 | name: {{.Name}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | annotations: 27 | {{range $k,$v := .Cluster.Spec.Annotations }} 28 | {{$k}}: {{$v}} 29 | {{end}} 30 | spec: 31 | replicas: {{.Cluster.Spec.UI.Replicas}} 32 | selector: 33 | matchLabels: 34 | {{range $k,$v := .Selector }} 35 | {{$k}}: {{$v}} 36 | {{end}} 37 | updateStrategy: 38 | type: RollingUpdate 39 | podManagementPolicy: Parallel 40 | template: 41 | metadata: 42 | labels: 43 | {{range $k,$v := .Labels }} 44 | {{$k}}: {{$v}} 45 | {{end}} 46 | annotations: 47 | {{range $k,$v := .Cluster.Spec.Annotations }} 48 | {{$k}}: {{$v}} 49 | {{end}} 50 | spec: 51 | terminationGracePeriodSeconds: 30 52 | nodeSelector: 53 | {{range $k,$v := .Cluster.Spec.NodeSelector }} 54 | {{$k}}: {{$v}} 55 | {{end}} 56 | containers: 57 | - name: airflow-ui 58 | args: 59 | - webserver 60 | image: {{.Cluster.Spec.UI.Image}}:{{.Cluster.Spec.UI.Version}} 61 | imagePullPolicy: IfNotPresent 62 | livenessProbe: 63 | failureThreshold: 5 64 | httpGet: 65 | path: /health 66 | port: web 67 | scheme: HTTP 68 | initialDelaySeconds: 100 69 | periodSeconds: 60 70 | successThreshold: 1 71 | timeoutSeconds: 2 72 | ports: 73 | - containerPort: 8080 74 | name: web 75 | protocol: TCP 76 | volumeMounts: 77 | - mountPath: /usr/local/airflow/dags/ 78 | name: dags-data 79 | volumes: 80 | - emptyDir: {} 81 | name: dags-data 82 | -------------------------------------------------------------------------------- /templates/worker-sts.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | apiVersion: apps/v1 18 | kind: StatefulSet 19 | metadata: 20 | name: {{.Name}} 21 | namespace: {{.Namespace}} 22 | labels: 23 | {{range $k,$v := .Labels }} 24 | {{$k}}: {{$v}} 25 | {{end}} 26 | annotations: 27 | {{range $k,$v := .Cluster.Spec.Annotations }} 28 | {{$k}}: {{$v}} 29 | {{end}} 30 | spec: 31 | replicas: {{.Cluster.Spec.Worker.Replicas}} 32 | serviceName: {{.Name}} 33 | selector: 34 | matchLabels: 35 | {{range $k,$v := .Selector }} 36 | {{$k}}: {{$v}} 37 | {{end}} 38 | updateStrategy: 39 | type: RollingUpdate 40 | podManagementPolicy: Parallel 41 | template: 42 | metadata: 43 | labels: 44 | {{range $k,$v := .Labels }} 45 | {{$k}}: {{$v}} 46 | {{end}} 47 | annotations: 48 | {{range $k,$v := .Cluster.Spec.Annotations }} 49 | {{$k}}: {{$v}} 50 | {{end}} 51 | spec: 52 | terminationGracePeriodSeconds: 30 53 | nodeSelector: 54 | {{range $k,$v := .Cluster.Spec.NodeSelector }} 55 | {{$k}}: {{$v}} 56 | {{end}} 57 | containers: 58 | - name: worker 59 | args: 60 | - worker 61 | image: {{.Cluster.Spec.Worker.Image}}:{{.Cluster.Spec.Worker.Version}} 62 | imagePullPolicy: IfNotPresent 63 | ports: 64 | - containerPort: 8793 65 | name: wlog 66 | volumeMounts: 67 | - mountPath: /usr/local/airflow/dags/ 68 | name: dags-data 69 | volumes: 70 | - emptyDir: {} 71 | name: dags-data 72 | -------------------------------------------------------------------------------- /test/e2e/base_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package airflowbase 17 | 18 | import ( 19 | "testing" 20 | 21 | . "github.com/onsi/ginkgo" 22 | . "github.com/onsi/gomega" 23 | "k8s.io/airflow-operator/pkg/apis/airflow/v1alpha1" 24 | _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" 25 | "sigs.k8s.io/controller-reconciler/pkg/test" 26 | ) 27 | 28 | const ( 29 | CRName = "AirflowBase" 30 | SampleDir = "../../hack/sample/" 31 | ) 32 | 33 | var f *test.Framework 34 | var ctx *test.Context 35 | 36 | func airflowBase(file string) *v1alpha1.AirflowBase { 37 | cr := &v1alpha1.AirflowBase{} 38 | if err := f.LoadFromFile(file, cr); err != nil { 39 | return nil 40 | } 41 | return cr 42 | } 43 | 44 | func Test(t *testing.T) { 45 | RegisterFailHandler(Fail) 46 | RunSpecs(t, CRName+" Suite") 47 | } 48 | 49 | var _ = BeforeSuite(func() { 50 | f = test.New(CRName) 51 | err := v1alpha1.SchemeBuilder.AddToScheme(f.GetScheme()) 52 | Expect(err).NotTo(HaveOccurred(), "failed to initialize the Framework: %v", err) 53 | f.Start() 54 | }) 55 | 56 | var _ = AfterSuite(func() { 57 | if ctx != nil { 58 | ctx.DeleteCR() 59 | } 60 | if f != nil { 61 | f.Stop() 62 | } 63 | }) 64 | 65 | func isBaseReady(cr interface{}) bool { 66 | stts := cr.(*v1alpha1.AirflowBase).Status 67 | return stts.IsReady() 68 | } 69 | 70 | var _ = Describe(CRName+" controller tests", func() { 71 | AfterEach(func() { 72 | ctx.DeleteCR() 73 | ctx = nil 74 | }) 75 | 76 | It("creating a "+CRName+" with mysql", func() { 77 | ctx = f.NewContext().WithCR(airflowBase(SampleDir + "mysql-celery/base.yaml")) 78 | cr := ctx.CR.(*v1alpha1.AirflowBase) 79 | By("creating a new " + CRName + ": " + cr.Name) 80 | ctx.CreateCR() 81 | ctx.WithTimeout(200).CheckStatefulSet(cr.Name+"-mysql", 1, 1) 82 | ctx.WithTimeout(10).CheckService(cr.Name+"-sql", map[string]int32{"mysql": 3306}) 83 | //ctx.WithTimeout(10).CheckSecret(name) 84 | ctx.WithTimeout(200).CheckStatefulSet(cr.Name+"-nfs", 1, 1) 85 | ctx.WithTimeout(200).CheckCR(isBaseReady) 86 | }) 87 | 88 | It("creating a "+CRName+" with postgres", func() { 89 | ctx = f.NewContext().WithCR(airflowBase(SampleDir + "postgres-celery/base.yaml")) 90 | cr := ctx.CR.(*v1alpha1.AirflowBase) 91 | By("creating a new " + CRName + ": " + cr.Name) 92 | ctx.CreateCR() 93 | ctx.WithTimeout(200).CheckStatefulSet(cr.Name+"-postgres", 1, 1) 94 | ctx.WithTimeout(10).CheckService(cr.Name+"-sql", map[string]int32{"postgres": 5432}) 95 | //ctx.WithTimeout(10).CheckSecret(name) 96 | ctx.WithTimeout(200).CheckStatefulSet(cr.Name+"-nfs", 1, 1) 97 | ctx.WithTimeout(200).CheckCR(isBaseReady) 98 | }) 99 | }) 100 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/finalizer/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package finalizer contains storage releated code 17 | // +k8s:deepcopy-gen=package,register 18 | package finalizer 19 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/finalizer/finalizer.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package finalizer 15 | 16 | import ( 17 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 18 | ) 19 | 20 | // const fileds 21 | const ( 22 | Cleanup = "sigapps.k8s.io/cleanup" 23 | ) 24 | 25 | // Exists adds the finalizer string 26 | func Exists(o metav1.Object, new string) bool { 27 | exists := false 28 | existing := o.GetFinalizers() 29 | for _, f := range existing { 30 | if f == new { 31 | exists = true 32 | break 33 | } 34 | } 35 | 36 | return exists 37 | } 38 | 39 | // Add adds the finalizer string 40 | func Add(o metav1.Object, new string) { 41 | exists := false 42 | existing := o.GetFinalizers() 43 | for _, f := range existing { 44 | if f == new { 45 | exists = true 46 | break 47 | } 48 | } 49 | 50 | if !exists { 51 | existing = append(existing, new) 52 | o.SetFinalizers(existing) 53 | } 54 | } 55 | 56 | // Remove removes the finalizer string 57 | func Remove(o metav1.Object, new string) { 58 | foundat := -1 59 | existing := o.GetFinalizers() 60 | for i, f := range existing { 61 | if f == new { 62 | foundat = i 63 | break 64 | } 65 | } 66 | if foundat != -1 { 67 | existing[foundat] = existing[len(existing)-1] 68 | o.SetFinalizers(existing[:len(existing)-1]) 69 | } 70 | } 71 | 72 | // EnsureStandard adds standard finalizers 73 | func EnsureStandard(o metav1.Object) { 74 | Add(o, Cleanup) 75 | } 76 | 77 | // RemoveStandard removes standard finalizers 78 | func RemoveStandard(o metav1.Object) { 79 | Remove(o, Cleanup) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/finalizer/finalizer_suite_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package finalizer_test 17 | 18 | import ( 19 | . "github.com/onsi/ginkgo" 20 | . "github.com/onsi/gomega" 21 | "testing" 22 | ) 23 | 24 | // TestEventhandler exports tests 25 | func TestEventhandler(t *testing.T) { 26 | RegisterFailHandler(Fail) 27 | RunSpecsWithDefaultAndCustomReporters(t, "Status Suite", []Reporter{}) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/finalizer/finalizer_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package finalizer_test 17 | 18 | import ( 19 | . "github.com/onsi/ginkgo" 20 | . "github.com/onsi/gomega" 21 | appsv1 "k8s.io/api/apps/v1" 22 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 | "sigs.k8s.io/controller-reconciler/pkg/finalizer" 24 | ) 25 | 26 | var _ = Describe("Finalizer", func() { 27 | 28 | deployment := &appsv1.Deployment{} 29 | BeforeEach(func() { 30 | deployment = &appsv1.Deployment{ 31 | ObjectMeta: metav1.ObjectMeta{ 32 | Name: "n-deploy", 33 | Namespace: "ns", 34 | }, 35 | } 36 | }) 37 | 38 | Describe("Finalizer", func() { 39 | It("Add finalizer", func(done Done) { 40 | Expect(len(deployment.ObjectMeta.Finalizers)).To(Equal(0)) 41 | finalizer.Add(deployment, finalizer.Cleanup) 42 | Expect(len(deployment.ObjectMeta.Finalizers)).To(Equal(1)) 43 | finalizer.Add(deployment, finalizer.Cleanup) 44 | Expect(len(deployment.ObjectMeta.Finalizers)).To(Equal(1)) 45 | finalizer.Add(deployment, "second") 46 | Expect(len(deployment.ObjectMeta.Finalizers)).To(Equal(2)) 47 | close(done) 48 | }) 49 | It("Remove finalizer", func(done Done) { 50 | Expect(len(deployment.ObjectMeta.Finalizers)).To(Equal(0)) 51 | finalizer.Add(deployment, finalizer.Cleanup) 52 | finalizer.Add(deployment, "second") 53 | Expect(len(deployment.ObjectMeta.Finalizers)).To(Equal(2)) 54 | finalizer.Remove(deployment, "second") 55 | Expect(len(deployment.ObjectMeta.Finalizers)).To(Equal(1)) 56 | finalizer.Remove(deployment, "second") 57 | Expect(len(deployment.ObjectMeta.Finalizers)).To(Equal(1)) 58 | finalizer.Remove(deployment, finalizer.Cleanup) 59 | Expect(len(deployment.ObjectMeta.Finalizers)).To(Equal(0)) 60 | close(done) 61 | }) 62 | }) 63 | }) 64 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/finalizer/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // +build !ignore_autogenerated 16 | 17 | // Code generated by main. DO NOT EDIT. 18 | 19 | package finalizer 20 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/genericreconciler/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package genericreconciler contains generic reconciler loop 17 | package genericreconciler 18 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/genericreconciler/genericreconciler_suite_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package genericreconciler_test 17 | 18 | import ( 19 | . "github.com/onsi/ginkgo" 20 | . "github.com/onsi/gomega" 21 | "testing" 22 | ) 23 | 24 | // TestEventhandler exports tests 25 | func TestEventhandler(t *testing.T) { 26 | RegisterFailHandler(Fail) 27 | RunSpecsWithDefaultAndCustomReporters(t, "Application Suite", []Reporter{}) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/genericreconciler/genericreconciler_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package genericreconciler_test 17 | 18 | import ( 19 | "context" 20 | . "github.com/onsi/ginkgo" 21 | . "github.com/onsi/gomega" 22 | appsv1 "k8s.io/api/apps/v1" 23 | corev1 "k8s.io/api/core/v1" 24 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 | "k8s.io/apimachinery/pkg/runtime" 26 | "k8s.io/apimachinery/pkg/types" 27 | "k8s.io/client-go/kubernetes/scheme" 28 | "sigs.k8s.io/controller-reconciler/pkg/genericreconciler" 29 | test "sigs.k8s.io/controller-reconciler/pkg/genericreconciler/v1alpha1" 30 | "sigs.k8s.io/controller-reconciler/pkg/reconciler" 31 | "sigs.k8s.io/controller-reconciler/pkg/reconciler/manager/k8s" 32 | "sigs.k8s.io/controller-runtime/pkg/client" 33 | "sigs.k8s.io/controller-runtime/pkg/client/fake" 34 | ) 35 | 36 | var AddToSchemes runtime.SchemeBuilder 37 | var _ = Describe("Reconciler", func() { 38 | cl := fake.NewFakeClient() 39 | AddToSchemes.AddToScheme(scheme.Scheme) 40 | gr := genericreconciler.Reconciler{} 41 | // TODO gr.CR = customresource.CustomResource{Handle: &test.Foo{}} 42 | gr.For(&test.Foo{}, test.SchemeGroupVersion). 43 | WithResourceManager(k8s.Getter(context.TODO(), cl, scheme.Scheme)). 44 | Using(&test.FooHandler{}) 45 | m1 := reconciler.KVMap{"k1": "v1"} 46 | m2 := reconciler.KVMap{"k2": "v2"} 47 | m3 := reconciler.KVMap{"k3": "v3"} 48 | 49 | BeforeEach(func() {}) 50 | 51 | Describe("Status", func() { 52 | It("should be able to Merge KVmap", func(done Done) { 53 | m1.Merge(m2, m3, reconciler.KVMap{"k3": "v3"}) 54 | Expect(len(m1)).To(Equal(3)) 55 | close(done) 56 | }) 57 | It("should not be able to Get non-existing deployment", func() { 58 | By("Getting a deployment") 59 | namespacedName := types.NamespacedName{ 60 | Name: "test-deployment", 61 | Namespace: "ns1", 62 | } 63 | obj := &appsv1.Deployment{} 64 | err := cl.Get(nil, namespacedName, obj) 65 | Expect(err).NotTo(BeNil()) 66 | }) 67 | It("should able to List Service", func() { 68 | By("Listing service") 69 | opts := client.ListOptions{} 70 | opts.Raw = &metav1.ListOptions{TypeMeta: metav1.TypeMeta{Kind: "Service", APIVersion: "v1"}} 71 | err := cl.List(context.TODO(), &opts, &corev1.ServiceList{}) 72 | Expect(err).To(BeNil()) 73 | }) 74 | It("should not be able to Reconcile missing custom resource", func() { 75 | By("Getting a deployment") 76 | namespacedName := types.NamespacedName{ 77 | Name: "crA", 78 | Namespace: "ns1", 79 | } 80 | _, err := gr.ReconcileResource(namespacedName) 81 | Expect(err).To(BeNil()) 82 | }) 83 | It("should be able to Reconcile custom resource", func() { 84 | By("Getting a deployment") 85 | cl.Create(context.TODO(), &test.Foo{ 86 | ObjectMeta: metav1.ObjectMeta{ 87 | Name: "crA", 88 | Namespace: "ns1", 89 | }, 90 | Spec: test.FooSpec{ 91 | Version: "", 92 | }, 93 | }) 94 | namespacedName := types.NamespacedName{ 95 | Name: "crA", 96 | Namespace: "ns1", 97 | } 98 | _, err := gr.ReconcileResource(namespacedName) 99 | Expect(err).To(BeNil()) 100 | sts := &appsv1.Deployment{} 101 | err = cl.Get(nil, types.NamespacedName{Name: "crA-deploy", Namespace: "ns1"}, sts) 102 | Expect(err).To(BeNil()) 103 | cm := &corev1.ConfigMap{} 104 | err = cl.Get(nil, types.NamespacedName{Name: "crA-cm", Namespace: "ns1"}, cm) 105 | Expect(err).To(BeNil()) 106 | }) 107 | 108 | }) 109 | }) 110 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/genericreconciler/handler.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package genericreconciler 15 | 16 | import ( 17 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 18 | "k8s.io/apimachinery/pkg/runtime" 19 | "reflect" 20 | "sigs.k8s.io/controller-reconciler/pkg/finalizer" 21 | "sigs.k8s.io/controller-reconciler/pkg/reconciler" 22 | "sigs.k8s.io/controller-reconciler/pkg/reconciler/manager" 23 | "strings" 24 | "time" 25 | ) 26 | 27 | // Constants defining labels 28 | const ( 29 | LabelResource = "custom-resource" 30 | LabelResourceName = "custom-resource-name" 31 | LabelResourceNamespace = "custom-resource-namespace" 32 | LabelUsing = "using" 33 | ) 34 | 35 | // Handler is an interface for operating on logical Components of a resource 36 | type Handler interface { 37 | Objects(api interface{}, labels map[string]string, observed, dependent, aggregated []reconciler.Object) ([]reconciler.Object, error) 38 | Observables(api interface{}, labels map[string]string, dependent []reconciler.Object) []reconciler.Observable 39 | } 40 | 41 | // StatusInterface - interface to update compoennt status 42 | type StatusInterface interface { 43 | UpdateStatus(api interface{}, reconciled []reconciler.Object, err error) time.Duration 44 | } 45 | 46 | // FinalizeInterface - finalize component 47 | type FinalizeInterface interface { 48 | Finalize(api interface{}, dependent, observed []reconciler.Object) error 49 | } 50 | 51 | // DiffersInterface - call differs 52 | type DiffersInterface interface { 53 | Differs(expected reconciler.Object, observed reconciler.Object) bool 54 | } 55 | 56 | // DependentResourcesInterface - get dependent resources 57 | type DependentResourcesInterface interface { 58 | DependentResources(api interface{}) []reconciler.Object 59 | } 60 | 61 | // getLabels return 62 | func getLabels(ro runtime.Object, using string) map[string]string { 63 | r := ro.(metav1.Object) 64 | return map[string]string{ 65 | LabelResource: strings.Trim(reflect.TypeOf(r).String(), "*"), 66 | LabelResourceName: r.GetName(), 67 | LabelResourceNamespace: r.GetNamespace(), 68 | LabelUsing: strings.Trim(using, "*"), 69 | } 70 | } 71 | 72 | // dependentResources Get dependent resources from component or defaults 73 | func dependentResources(h Handler, resource runtime.Object) []reconciler.Object { 74 | if s, ok := h.(DependentResourcesInterface); ok { 75 | return s.DependentResources(resource) 76 | } 77 | return []reconciler.Object{} 78 | } 79 | 80 | // differs - call differs 81 | func differs(h Handler, expected reconciler.Object, observed reconciler.Object) bool { 82 | if s, ok := h.(DiffersInterface); ok { 83 | return s.Differs(expected, observed) 84 | } 85 | return true 86 | } 87 | 88 | // finalize - Finalize component 89 | func finalize(h Handler, resource runtime.Object, observed, dependent []reconciler.Object) error { 90 | if s, ok := h.(FinalizeInterface); ok { 91 | return s.Finalize(resource, observed, dependent) 92 | } 93 | r := resource.(metav1.Object) 94 | finalizer.RemoveStandard(r) 95 | return nil 96 | } 97 | 98 | // updateStatus - update component status 99 | func updateStatus(h Handler, resource runtime.Object, reconciled []reconciler.Object, err error) time.Duration { 100 | var period time.Duration 101 | if s, ok := h.(StatusInterface); ok { 102 | return s.UpdateStatus(resource, reconciled, err) 103 | } 104 | return period 105 | } 106 | 107 | // getAllObservables - get all observables 108 | func getAllObservables(rsrcmgr *manager.ResourceManager, bag []reconciler.Object, labels map[string]string) []reconciler.Observable { 109 | var observables []reconciler.Observable 110 | for _, m := range rsrcmgr.All() { 111 | o := m.ObservablesFromObjects(bag, labels) 112 | observables = append(observables, o...) 113 | } 114 | return observables 115 | } 116 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/genericreconciler/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package genericreconciler 15 | 16 | import ( 17 | "k8s.io/apimachinery/pkg/runtime" 18 | "k8s.io/apimachinery/pkg/runtime/schema" 19 | rm "sigs.k8s.io/controller-reconciler/pkg/reconciler/manager" 20 | "sigs.k8s.io/controller-runtime/pkg/manager" 21 | "sigs.k8s.io/controller-runtime/pkg/reconcile" 22 | ) 23 | 24 | var _ reconcile.Reconciler = &Reconciler{} 25 | 26 | // Reconciler defines fields needed for all airflow controllers 27 | // +k8s:deepcopy-gen=false 28 | type Reconciler struct { 29 | gv schema.GroupVersion 30 | errorHandler func(interface{}, error, string) 31 | validate func(interface{}) error 32 | applyDefaults func(interface{}) 33 | resource runtime.Object 34 | manager manager.Manager 35 | rsrcMgr rm.ResourceManager 36 | using []Handler 37 | } 38 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/genericreconciler/v1alpha1/crfoo.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package v1alpha1 17 | 18 | import ( 19 | appsv1 "k8s.io/api/apps/v1" 20 | corev1 "k8s.io/api/core/v1" 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | "k8s.io/client-go/kubernetes/scheme" 24 | "log" 25 | "sigs.k8s.io/controller-reconciler/pkg/reconciler" 26 | "sigs.k8s.io/controller-reconciler/pkg/reconciler/manager/k8s" 27 | crscheme "sigs.k8s.io/controller-runtime/pkg/runtime/scheme" 28 | ) 29 | 30 | var ( 31 | // SchemeBuilder is used to add go types to the GroupVersionKind scheme 32 | SchemeBuilder = &crscheme.Builder{ 33 | GroupVersion: schema.GroupVersion{ 34 | Group: "foo.cloud.google.com", 35 | Version: "v1alpha1", 36 | }, 37 | } 38 | // SchemeGroupVersion - GV 39 | SchemeGroupVersion = schema.GroupVersion{ 40 | Group: "foo.cloud.google.com", 41 | Version: "v1alpha1", 42 | } 43 | ) 44 | 45 | // Foo test custom resource 46 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 47 | type Foo struct { 48 | metav1.TypeMeta `json:",inline"` 49 | metav1.ObjectMeta `json:"metadata,omitempty"` 50 | Spec FooSpec `json:"spec,omitempty"` 51 | Status FooStatus `json:"status,omitempty"` 52 | } 53 | 54 | // FooSpec CR foo spec 55 | type FooSpec struct { 56 | Version string 57 | } 58 | 59 | // FooList contains a list of Foo 60 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 61 | type FooList struct { 62 | metav1.TypeMeta `json:",inline"` 63 | metav1.ListMeta `json:"metadata,omitempty"` 64 | Items []Foo `json:"items"` 65 | } 66 | 67 | // FooStatus CR foo status 68 | type FooStatus struct { 69 | Status string 70 | Component string 71 | } 72 | 73 | // FooHandler handler 74 | type FooHandler struct{} 75 | 76 | // Objects - returns resources 77 | func (s *FooHandler) Objects(rsrc interface{}, rsrclabels map[string]string, observed, dependent, aggregate []reconciler.Object) ([]reconciler.Object, error) { 78 | var resources []reconciler.Object 79 | r := rsrc.(*Foo) 80 | n := r.ObjectMeta.Name 81 | ns := r.ObjectMeta.Namespace 82 | resources = append(resources, 83 | []reconciler.Object{ 84 | { 85 | Lifecycle: reconciler.LifecycleManaged, 86 | Type: k8s.Type, 87 | Obj: &k8s.Object{ 88 | ObjList: &appsv1.DeploymentList{}, 89 | Obj: &appsv1.Deployment{ 90 | ObjectMeta: metav1.ObjectMeta{ 91 | Name: n + "-deploy", 92 | Namespace: ns, 93 | Labels: rsrclabels, 94 | }, 95 | }, 96 | }, 97 | }, 98 | { 99 | Lifecycle: reconciler.LifecycleManaged, 100 | Type: k8s.Type, 101 | Obj: &k8s.Object{ 102 | ObjList: &corev1.ConfigMapList{}, 103 | Obj: &corev1.ConfigMap{ 104 | ObjectMeta: metav1.ObjectMeta{ 105 | Name: n + "-cm", 106 | Namespace: ns, 107 | Labels: rsrclabels, 108 | }, 109 | Data: map[string]string{ 110 | "test-key": "test-value", 111 | }, 112 | }, 113 | }, 114 | }, 115 | }..., 116 | ) 117 | return resources, nil 118 | } 119 | 120 | // Observables - return selectors 121 | func (s *FooHandler) Observables(rsrc interface{}, rsrclabels map[string]string, dependent []reconciler.Object) []reconciler.Observable { 122 | return []reconciler.Observable{ 123 | { 124 | Type: k8s.Type, 125 | Obj: &k8s.Observable{ 126 | ObjList: &appsv1.DeploymentList{}, 127 | Labels: rsrclabels, 128 | Type: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1"}, 129 | }, 130 | }, 131 | { 132 | Type: k8s.Type, 133 | Obj: &k8s.Observable{ 134 | ObjList: &corev1.ConfigMapList{}, 135 | Labels: rsrclabels, 136 | Type: metav1.TypeMeta{Kind: "ConfigMap", APIVersion: "v1"}, 137 | }, 138 | }, 139 | } 140 | } 141 | 142 | func init() { 143 | SchemeBuilder.Register(&Foo{}, &FooList{}) 144 | err := SchemeBuilder.AddToScheme(scheme.Scheme) 145 | if err != nil { 146 | log.Fatal(err) 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/genericreconciler/v1alpha1/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package v1alpha1 contains test custom resource 17 | // +k8s:deepcopy-gen=package,register 18 | package v1alpha1 19 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/genericreconciler/v1alpha1/testutil.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package v1alpha1 contains test custom resource 17 | //go:generate go run ../../../vendor/k8s.io/code-generator/cmd/deepcopy-gen/main.go -O zz_generated.deepcopy -i ./... -h ../../../hack/boilerplate.go.txt 18 | package v1alpha1 19 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/genericreconciler/v1alpha1/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // +build !ignore_autogenerated 16 | 17 | // Code generated by main. DO NOT EDIT. 18 | 19 | package v1alpha1 20 | 21 | import ( 22 | runtime "k8s.io/apimachinery/pkg/runtime" 23 | ) 24 | 25 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 26 | func (in *Foo) DeepCopyInto(out *Foo) { 27 | *out = *in 28 | out.TypeMeta = in.TypeMeta 29 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 30 | out.Spec = in.Spec 31 | out.Status = in.Status 32 | return 33 | } 34 | 35 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Foo. 36 | func (in *Foo) DeepCopy() *Foo { 37 | if in == nil { 38 | return nil 39 | } 40 | out := new(Foo) 41 | in.DeepCopyInto(out) 42 | return out 43 | } 44 | 45 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 46 | func (in *Foo) DeepCopyObject() runtime.Object { 47 | if c := in.DeepCopy(); c != nil { 48 | return c 49 | } 50 | return nil 51 | } 52 | 53 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 54 | func (in *FooHandler) DeepCopyInto(out *FooHandler) { 55 | *out = *in 56 | return 57 | } 58 | 59 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FooHandler. 60 | func (in *FooHandler) DeepCopy() *FooHandler { 61 | if in == nil { 62 | return nil 63 | } 64 | out := new(FooHandler) 65 | in.DeepCopyInto(out) 66 | return out 67 | } 68 | 69 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 70 | func (in *FooList) DeepCopyInto(out *FooList) { 71 | *out = *in 72 | out.TypeMeta = in.TypeMeta 73 | out.ListMeta = in.ListMeta 74 | if in.Items != nil { 75 | in, out := &in.Items, &out.Items 76 | *out = make([]Foo, len(*in)) 77 | for i := range *in { 78 | (*in)[i].DeepCopyInto(&(*out)[i]) 79 | } 80 | } 81 | return 82 | } 83 | 84 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FooList. 85 | func (in *FooList) DeepCopy() *FooList { 86 | if in == nil { 87 | return nil 88 | } 89 | out := new(FooList) 90 | in.DeepCopyInto(out) 91 | return out 92 | } 93 | 94 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 95 | func (in *FooList) DeepCopyObject() runtime.Object { 96 | if c := in.DeepCopy(); c != nil { 97 | return c 98 | } 99 | return nil 100 | } 101 | 102 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 103 | func (in *FooSpec) DeepCopyInto(out *FooSpec) { 104 | *out = *in 105 | return 106 | } 107 | 108 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FooSpec. 109 | func (in *FooSpec) DeepCopy() *FooSpec { 110 | if in == nil { 111 | return nil 112 | } 113 | out := new(FooSpec) 114 | in.DeepCopyInto(out) 115 | return out 116 | } 117 | 118 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 119 | func (in *FooStatus) DeepCopyInto(out *FooStatus) { 120 | *out = *in 121 | return 122 | } 123 | 124 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FooStatus. 125 | func (in *FooStatus) DeepCopy() *FooStatus { 126 | if in == nil { 127 | return nil 128 | } 129 | out := new(FooStatus) 130 | in.DeepCopyInto(out) 131 | return out 132 | } 133 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/reconciler/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package reconciler contains resource methods 17 | package reconciler 18 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/reconciler/manager/gcp/utils.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package gcp 15 | 16 | import ( 17 | "cloud.google.com/go/compute/metadata" 18 | "flag" 19 | "google.golang.org/api/googleapi" 20 | "net/http" 21 | "regexp" 22 | "sigs.k8s.io/controller-reconciler/pkg/reconciler" 23 | "strings" 24 | ) 25 | 26 | var ( 27 | projectID, zone string 28 | ) 29 | 30 | func init() { 31 | // TODO: Fix this to allow double vendoring this library but still register flags on behalf of users 32 | flag.StringVar(&projectID, "gcpproject", "", 33 | "GCP Project ID. Required for outside cluster.") 34 | flag.StringVar(&zone, "gcpzone", "", 35 | "GCP Zone. Required for outside cluster.") 36 | } 37 | 38 | // CompliantLabelString - convert to GCP compliant string 39 | // https://cloud.google.com/resource-manager/docs/creating-managing-labels 40 | func CompliantLabelString(s string) string { 41 | s = strings.ToLower(s) 42 | reg, _ := regexp.Compile("[^a-z0-9_-]+") 43 | s = reg.ReplaceAllString(s, "-") 44 | return s 45 | } 46 | 47 | // CompliantLabelMap - convert to GCP compliant map 48 | // https://cloud.google.com/resource-manager/docs/creating-managing-labels 49 | func CompliantLabelMap(in map[string]string) map[string]string { 50 | out := make(map[string]string) 51 | for k, v := range in { 52 | out[CompliantLabelString(k)] = CompliantLabelString(v) 53 | } 54 | return out 55 | } 56 | 57 | // IsNotAuthorized - true if not-authorized error is returned 58 | func IsNotAuthorized(err error) bool { 59 | return isGoogleErrorWithCode(err, http.StatusForbidden) 60 | } 61 | 62 | // IsNotFound - true if not-found error is returned 63 | func IsNotFound(err error) bool { 64 | return isGoogleErrorWithCode(err, http.StatusNotFound) 65 | } 66 | 67 | func isGoogleErrorWithCode(err error, code int) bool { 68 | if err == nil { 69 | return false 70 | } 71 | if ge, ok := err.(*googleapi.Error); ok { 72 | return ge.Code == code 73 | } 74 | return false 75 | } 76 | 77 | // GetProjectFromMetadata - get metadata 78 | func GetProjectFromMetadata() (string, error) { 79 | if projectID != "" { 80 | return projectID, nil 81 | } 82 | return metadata.ProjectID() 83 | } 84 | 85 | // GetZoneFromMetadata - get metadata 86 | func GetZoneFromMetadata() (string, error) { 87 | if zone != "" { 88 | return zone, nil 89 | } 90 | return metadata.Zone() 91 | } 92 | 93 | // GetFilterStringFromLabels returns filter string 94 | func GetFilterStringFromLabels(map[string]string) string { 95 | return "" 96 | } 97 | 98 | // Objects internal 99 | type Objects struct { 100 | err error 101 | context interface{} 102 | bag []reconciler.Object 103 | labels map[string]string 104 | } 105 | 106 | // NewObjects returns nag 107 | func NewObjects() *Objects { 108 | return &Objects{ 109 | bag: []reconciler.Object{}, 110 | } 111 | } 112 | 113 | //WithContext injects context for mutators 114 | func (b *Objects) WithContext(context interface{}) *Objects { 115 | b.context = context 116 | return b 117 | } 118 | 119 | //WithLabels injects labels 120 | func (b *Objects) WithLabels(labels map[string]string) *Objects { 121 | b.labels = labels 122 | return b 123 | } 124 | 125 | //Build - process 126 | func (b *Objects) Build() ([]reconciler.Object, error) { 127 | return b.bag, b.err 128 | } 129 | 130 | // Add - add obj 131 | func (b *Objects) Add(o *reconciler.Object, err error) *Objects { 132 | if err != nil { 133 | b.err = err 134 | } else { 135 | o.Obj.SetLabels(b.labels) 136 | b.bag = append(b.bag, *o) 137 | } 138 | return b 139 | } 140 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/reconciler/manager/interface.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package manager 15 | 16 | import ( 17 | "sigs.k8s.io/controller-reconciler/pkg/reconciler" 18 | ) 19 | 20 | // Manager is an interface for operating on CRs 21 | type Manager interface { 22 | Observe(observables ...reconciler.Observable) ([]reconciler.Object, error) 23 | Update(item reconciler.Object) error 24 | Create(item reconciler.Object) error 25 | Delete(item reconciler.Object) error 26 | SpecDiffers(expected, observed *reconciler.Object) bool 27 | ObservablesFromObjects(bag []reconciler.Object, labels map[string]string) []reconciler.Observable 28 | } 29 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/reconciler/manager/internal.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package manager 15 | 16 | import () 17 | 18 | // Add Register resource manager 19 | func (rm *ResourceManager) Add(rsrcType string, m Manager) { 20 | if rm.rsrcmgrs == nil { 21 | rm.rsrcmgrs = make(map[string]Manager) 22 | } 23 | rm.rsrcmgrs[rsrcType] = m 24 | } 25 | 26 | // Get resource manager 27 | func (rm *ResourceManager) Get(rsrcType string) Manager { 28 | m, ok := rm.rsrcmgrs[rsrcType] 29 | if ok { 30 | return m 31 | } 32 | return nil 33 | } 34 | 35 | // All returns all managers 36 | func (rm *ResourceManager) All() map[string]Manager { 37 | return rm.rsrcmgrs 38 | } 39 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/reconciler/manager/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package manager 15 | 16 | // ResourceManager is an interface for operating on CRs 17 | type ResourceManager struct { 18 | rsrcmgrs map[string]Manager 19 | } 20 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/reconciler/resource.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package reconciler 15 | 16 | import ( 17 | "math/rand" 18 | "time" 19 | ) 20 | 21 | // Password char space 22 | const ( 23 | PasswordCharNumSpace = "abcdefghijklmnopqrstuvwxyz0123456789" 24 | PasswordCharSpace = "abcdefghijklmnopqrstuvwxyz" 25 | ) 26 | 27 | var ( 28 | random = rand.New(rand.NewSource(time.Now().UnixNano())) 29 | ) 30 | 31 | // RandomAlphanumericString generates a random password of some fixed length. 32 | func RandomAlphanumericString(strlen int) string { 33 | result := make([]byte, strlen) 34 | for i := range result { 35 | result[i] = PasswordCharNumSpace[random.Intn(len(PasswordCharNumSpace))] 36 | } 37 | result[0] = PasswordCharSpace[random.Intn(len(PasswordCharSpace))] 38 | return string(result[:strlen]) 39 | } 40 | 41 | // NoUpdate - set lifecycle to noupdate 42 | // Manage by Create Only, Delete. 43 | func NoUpdate(o *Object, v interface{}) { 44 | o.Lifecycle = LifecycleNoUpdate 45 | } 46 | 47 | // DecorateOnly - set lifecycle to decorate 48 | // Manage by update only. Dont create or delete 49 | func DecorateOnly(o *Object, v interface{}) { 50 | o.Lifecycle = LifecycleDecorate 51 | } 52 | 53 | // Merge is used to merge multiple maps into the target map 54 | func (out KVMap) Merge(kvmaps ...KVMap) { 55 | for _, kvmap := range kvmaps { 56 | for k, v := range kvmap { 57 | out[k] = v 58 | } 59 | } 60 | } 61 | 62 | // ObjectsByType get items from the Object bag 63 | func ObjectsByType(in []Object, t string) []Object { 64 | var out []Object 65 | for _, item := range in { 66 | if item.Type == t { 67 | out = append(out, item) 68 | } 69 | } 70 | return out 71 | } 72 | 73 | // DeleteAt object at index 74 | func DeleteAt(in []Object, index int) []Object { 75 | var out []Object 76 | in[index] = in[len(in)-1] 77 | out = in[:len(in)-1] 78 | return out 79 | } 80 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/reconciler/resource_suite_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package reconciler_test 17 | 18 | import ( 19 | . "github.com/onsi/ginkgo" 20 | . "github.com/onsi/gomega" 21 | "testing" 22 | ) 23 | 24 | // TestEventhandler exports tests 25 | func TestEventhandler(t *testing.T) { 26 | RegisterFailHandler(Fail) 27 | RunSpecsWithDefaultAndCustomReporters(t, "Resource Suite", []Reporter{}) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/reconciler/testdata/sts.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | name: {{.Name}} 5 | namespace: {{.Namespace}} 6 | labels: 7 | {{range $k,$v := .Labels }} 8 | {{$k}}: {{$v}} 9 | {{end}} 10 | spec: 11 | serviceName: {{.Name}} 12 | # go template syntax replicas: with $n := index .Spec.NodeGroups 0 $n.Replicas end 13 | replicas: {{.Replicas}} 14 | selector: 15 | matchLabels: 16 | {{range $k,$v := .Selector }} 17 | {{$k}}: {{$v}} 18 | {{end}} 19 | updateStrategy: 20 | # https://www.elastic.co/guide/en/elasticsearch/reference/current/rolling-upgrades.html 21 | type: OnDelete 22 | podManagementPolicy: OrderedReady 23 | template: 24 | metadata: 25 | labels: 26 | {{range $k,$v := .Labels }} 27 | {{$k}}: {{$v}} 28 | {{end}} 29 | spec: 30 | containers: 31 | - name: foobar 32 | image: {{.Image}}:{{.Version}} 33 | ports: 34 | - containerPort: 8080 35 | name: http 36 | env: 37 | - name: NODENAME 38 | valueFrom: 39 | fieldRef: 40 | fieldPath: metadata.name 41 | - name: PROCESSORS 42 | valueFrom: 43 | resourceFieldRef: 44 | resource: limits.cpu 45 | readinessProbe: 46 | httpGet: 47 | path: /health?local=true 48 | port: 8080 49 | initialDelaySeconds: 5 50 | volumeMounts: 51 | - name: config 52 | mountPath: /etc/config/config.yml 53 | volumes: 54 | - name: config 55 | configMap: 56 | name: {{.Name}} 57 | volumeClaimTemplates: 58 | - metadata: 59 | name: data 60 | labels: 61 | {{range $k,$v := .Labels }} 62 | {{$k}}: {{$v}} 63 | {{end}} 64 | spec: 65 | accessModes: 66 | - ReadWriteOnce 67 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/reconciler/testdata/unknown_rsrc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Something 3 | metadata: 4 | name: {{.Name}} 5 | namespace: {{.Namespace}} 6 | labels: 7 | {{range $k,$v := .Labels }} 8 | {{$k}}: {{$v}} 9 | {{end}} 10 | spec: 11 | ports: 12 | - port: 8080 13 | name: http 14 | selector: 15 | {{range $k,$v := .Selector }} 16 | {{$k}}: {{$v}} 17 | {{end}} 18 | type: ClusterIP 19 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/reconciler/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package reconciler 15 | 16 | import ( 17 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 18 | ) 19 | 20 | // Common const definitions 21 | const ( 22 | LifecycleManaged = "managed" // CRUD 23 | LifecycleReferred = "referred" // R 24 | LifecycleNoUpdate = "noupdate" // CRD 25 | LifecycleDecorate = "decorate" // RU 26 | ) 27 | 28 | // ObjectInterface - 29 | type ObjectInterface interface { 30 | GetName() string 31 | IsSameAs(interface{}) bool 32 | SetOwnerReferences(*metav1.OwnerReference) bool 33 | SetLabels(labels map[string]string) 34 | } 35 | 36 | // Object is a container to capture the k8s resource info to be used by controller 37 | type Object struct { 38 | // Lifecycle can be: managed, reference 39 | Lifecycle string 40 | // Type - object type 41 | Type string 42 | // Obj - object 43 | Obj ObjectInterface 44 | // Delete - marker for deletion 45 | Delete bool 46 | // Update - marker for update 47 | Update bool 48 | } 49 | 50 | // Observable captures the k8s resource info and selector to fetch child resources 51 | type Observable struct { 52 | // Type - object type 53 | Type string 54 | // Obj - object 55 | Obj interface{} 56 | } 57 | 58 | // KVMap is a map[string]string 59 | type KVMap map[string]string 60 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/status/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package status contains status releated code 17 | package status 18 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/status/status.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package status 15 | 16 | import ( 17 | //"fmt" 18 | appsv1 "k8s.io/api/apps/v1" 19 | policyv1 "k8s.io/api/policy/v1beta1" 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "sigs.k8s.io/controller-reconciler/pkg/reconciler" 23 | "sigs.k8s.io/controller-reconciler/pkg/reconciler/manager/k8s" 24 | ) 25 | 26 | // Constants defining labels 27 | const ( 28 | StatusReady = "Ready" 29 | StatusInProgress = "InProgress" 30 | StatusDisabled = "Disabled" 31 | ) 32 | 33 | func (s *Statefulset) update(rsrc *appsv1.StatefulSet) string { 34 | s.Replicas = rsrc.Status.Replicas 35 | s.ReadyReplicas = rsrc.Status.ReadyReplicas 36 | s.CurrentReplicas = rsrc.Status.CurrentReplicas 37 | if rsrc.Status.ReadyReplicas == *rsrc.Spec.Replicas && rsrc.Status.CurrentReplicas == *rsrc.Spec.Replicas { 38 | return StatusReady 39 | } 40 | return StatusInProgress 41 | } 42 | 43 | func (s *ObjectStatus) update(rsrc metav1.Object) { 44 | ro := rsrc.(runtime.Object) 45 | gvk := ro.GetObjectKind().GroupVersionKind() 46 | s.Link = rsrc.GetSelfLink() 47 | s.Name = rsrc.GetName() 48 | s.Group = gvk.GroupVersion().String() 49 | s.Kind = gvk.GroupKind().Kind 50 | s.Status = StatusReady 51 | } 52 | 53 | // Pdb is a generic status holder for pdb 54 | func (s *Pdb) update(rsrc *policyv1.PodDisruptionBudget) string { 55 | s.CurrentHealthy = rsrc.Status.CurrentHealthy 56 | s.DesiredHealthy = rsrc.Status.DesiredHealthy 57 | if s.CurrentHealthy >= s.DesiredHealthy { 58 | return StatusReady 59 | } 60 | return StatusInProgress 61 | } 62 | 63 | // ResetComponentList - reset component list objects 64 | func (cm *ComponentMeta) ResetComponentList() { 65 | cm.ComponentList.Objects = []ObjectStatus{} 66 | } 67 | 68 | // UpdateStatus the component status 69 | func (cm *ComponentMeta) UpdateStatus(items []reconciler.Object) bool { 70 | var ready = true 71 | for _, item := range items { 72 | r := item.Obj.(*k8s.Object) 73 | os := ObjectStatus{} 74 | os.update(r.Obj) 75 | switch r.Obj.(type) { 76 | case *appsv1.StatefulSet: 77 | os.ExtendedStatus.STS = &Statefulset{} 78 | os.Status = os.ExtendedStatus.STS.update(r.Obj.(*appsv1.StatefulSet)) 79 | case *policyv1.PodDisruptionBudget: 80 | os.ExtendedStatus.PDB = &Pdb{} 81 | os.Status = os.ExtendedStatus.PDB.update(r.Obj.(*policyv1.PodDisruptionBudget)) 82 | } 83 | cm.ComponentList.Objects = append(cm.ComponentList.Objects, os) 84 | } 85 | for _, os := range cm.ComponentList.Objects { 86 | if os.Status != StatusReady { 87 | ready = false 88 | } 89 | } 90 | 91 | return ready 92 | } 93 | 94 | // UpdateStatus the component status 95 | func (m *Meta) UpdateStatus(componentready *bool, err error) { 96 | if componentready != nil { 97 | if *componentready { 98 | m.Ready("ComponentsReady", "all components ready") 99 | } else { 100 | m.NotReady("ComponentsNotReady", "some components not ready") 101 | } 102 | } 103 | if err != nil { 104 | m.SetCondition(Error, "ErrorSeen", err.Error()) 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/status/status_suite_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package status_test 17 | 18 | import ( 19 | . "github.com/onsi/ginkgo" 20 | . "github.com/onsi/gomega" 21 | "testing" 22 | ) 23 | 24 | // TestEventhandler exports tests 25 | func TestEventhandler(t *testing.T) { 26 | RegisterFailHandler(Fail) 27 | RunSpecsWithDefaultAndCustomReporters(t, "Status Suite", []Reporter{}) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/status/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // +build !ignore_autogenerated 17 | 18 | // Code generated by main. DO NOT EDIT. 19 | 20 | package status 21 | 22 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 23 | func (in *ComponentList) DeepCopyInto(out *ComponentList) { 24 | *out = *in 25 | if in.Objects != nil { 26 | in, out := &in.Objects, &out.Objects 27 | *out = make([]ObjectStatus, len(*in)) 28 | for i := range *in { 29 | (*in)[i].DeepCopyInto(&(*out)[i]) 30 | } 31 | } 32 | return 33 | } 34 | 35 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentList. 36 | func (in *ComponentList) DeepCopy() *ComponentList { 37 | if in == nil { 38 | return nil 39 | } 40 | out := new(ComponentList) 41 | in.DeepCopyInto(out) 42 | return out 43 | } 44 | 45 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 46 | func (in *ComponentMeta) DeepCopyInto(out *ComponentMeta) { 47 | *out = *in 48 | in.ComponentList.DeepCopyInto(&out.ComponentList) 49 | return 50 | } 51 | 52 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentMeta. 53 | func (in *ComponentMeta) DeepCopy() *ComponentMeta { 54 | if in == nil { 55 | return nil 56 | } 57 | out := new(ComponentMeta) 58 | in.DeepCopyInto(out) 59 | return out 60 | } 61 | 62 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 63 | func (in *Condition) DeepCopyInto(out *Condition) { 64 | *out = *in 65 | in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) 66 | in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) 67 | return 68 | } 69 | 70 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition. 71 | func (in *Condition) DeepCopy() *Condition { 72 | if in == nil { 73 | return nil 74 | } 75 | out := new(Condition) 76 | in.DeepCopyInto(out) 77 | return out 78 | } 79 | 80 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 81 | func (in *ExtendedStatus) DeepCopyInto(out *ExtendedStatus) { 82 | *out = *in 83 | if in.STS != nil { 84 | in, out := &in.STS, &out.STS 85 | *out = new(Statefulset) 86 | **out = **in 87 | } 88 | if in.PDB != nil { 89 | in, out := &in.PDB, &out.PDB 90 | *out = new(Pdb) 91 | **out = **in 92 | } 93 | return 94 | } 95 | 96 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtendedStatus. 97 | func (in *ExtendedStatus) DeepCopy() *ExtendedStatus { 98 | if in == nil { 99 | return nil 100 | } 101 | out := new(ExtendedStatus) 102 | in.DeepCopyInto(out) 103 | return out 104 | } 105 | 106 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 107 | func (in *Meta) DeepCopyInto(out *Meta) { 108 | *out = *in 109 | if in.Conditions != nil { 110 | in, out := &in.Conditions, &out.Conditions 111 | *out = make([]Condition, len(*in)) 112 | for i := range *in { 113 | (*in)[i].DeepCopyInto(&(*out)[i]) 114 | } 115 | } 116 | return 117 | } 118 | 119 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Meta. 120 | func (in *Meta) DeepCopy() *Meta { 121 | if in == nil { 122 | return nil 123 | } 124 | out := new(Meta) 125 | in.DeepCopyInto(out) 126 | return out 127 | } 128 | 129 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 130 | func (in *ObjectStatus) DeepCopyInto(out *ObjectStatus) { 131 | *out = *in 132 | in.ExtendedStatus.DeepCopyInto(&out.ExtendedStatus) 133 | return 134 | } 135 | 136 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectStatus. 137 | func (in *ObjectStatus) DeepCopy() *ObjectStatus { 138 | if in == nil { 139 | return nil 140 | } 141 | out := new(ObjectStatus) 142 | in.DeepCopyInto(out) 143 | return out 144 | } 145 | 146 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 147 | func (in *Statefulset) DeepCopyInto(out *Statefulset) { 148 | *out = *in 149 | return 150 | } 151 | 152 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Statefulset. 153 | func (in *Statefulset) DeepCopy() *Statefulset { 154 | if in == nil { 155 | return nil 156 | } 157 | out := new(Statefulset) 158 | in.DeepCopyInto(out) 159 | return out 160 | } 161 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/storage/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package storage contains storage releated code 17 | // +k8s:deepcopy-gen=package,register 18 | package storage 19 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/storage/storage.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package storage 15 | 16 | import ( 17 | "k8s.io/apimachinery/pkg/util/validation/field" 18 | ) 19 | 20 | // Validate validates the storage spec 21 | func (s *Spec) Validate(fp *field.Path, sfield string, errs field.ErrorList, noneok bool, one bool, smap map[string]string) field.ErrorList { 22 | fp = fp.Child(sfield) 23 | if s == nil { 24 | if !noneok { 25 | errs = append(errs, field.Required(fp, "Required storage spec missing.")) 26 | } 27 | return errs 28 | } 29 | 30 | found := 0 31 | if val, ok := smap[FieldGCS]; ok { 32 | if s.GCS != nil { 33 | found++ 34 | } else if val == Expected { 35 | errs = append(errs, field.Required(fp.Child("gcs"), "gcs spec missing")) 36 | } 37 | } else if s.GCS != nil { 38 | errs = append(errs, field.Invalid(fp.Child("gcs"), "", "gcs spec not supported")) 39 | } 40 | 41 | if val, ok := smap[FieldNFS]; ok { 42 | if s.NFS != nil { 43 | found++ 44 | } else if val == Expected { 45 | errs = append(errs, field.Required(fp.Child("nfs"), "nfs spec missing")) 46 | } 47 | } else if s.NFS != nil { 48 | errs = append(errs, field.Invalid(fp.Child("nfs"), "", "nfs spec not supported")) 49 | } 50 | 51 | if val, ok := smap[FieldFS]; ok { 52 | if s.FS != nil { 53 | found++ 54 | } else if val == Expected { 55 | errs = append(errs, field.Required(fp.Child("fs"), "fs spec missing")) 56 | } 57 | } else if s.FS != nil { 58 | errs = append(errs, field.Invalid(fp.Child("fs"), "", "fs spec not supported")) 59 | } 60 | 61 | if found == 0 { 62 | if !noneok { 63 | errs = append(errs, field.Invalid(fp, "", "No storage specs present.")) 64 | } 65 | } else if found > 1 && one { 66 | errs = append(errs, field.Invalid(fp, "", "Expecting only one storage. Multiple present.")) 67 | } 68 | return errs 69 | } 70 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/storage/storage_suite_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package storage_test 17 | 18 | import ( 19 | . "github.com/onsi/ginkgo" 20 | . "github.com/onsi/gomega" 21 | "testing" 22 | ) 23 | 24 | // TestEventhandler exports tests 25 | func TestEventhandler(t *testing.T) { 26 | RegisterFailHandler(Fail) 27 | RunSpecsWithDefaultAndCustomReporters(t, "Status Suite", []Reporter{}) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/storage/storage_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one or more 2 | // contributor license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright ownership. 4 | // The ASF licenses this file to You under the Apache License, Version 2.0 5 | // (the "License"); you may not use this file except in compliance with 6 | // the License. You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package storage_test 17 | 18 | import ( 19 | "fmt" 20 | . "github.com/onsi/ginkgo" 21 | . "github.com/onsi/gomega" 22 | corev1 "k8s.io/api/core/v1" 23 | "k8s.io/apimachinery/pkg/util/validation/field" 24 | "sigs.k8s.io/controller-reconciler/pkg/storage" 25 | ) 26 | 27 | var _ = Describe("Resource", func() { 28 | gcs := storage.GCS{ 29 | Bucket: "asdasd", 30 | ReadOnly: true, 31 | } 32 | nfs := corev1.NFSVolumeSource{ 33 | Server: "asdasd", 34 | Path: "/asd", 35 | } 36 | gcsonly := storage.Spec{GCS: &gcs} 37 | nfsonly := storage.Spec{NFS: &nfs} 38 | both := storage.Spec{GCS: &gcs, NFS: &nfs} 39 | none := storage.Spec{} 40 | fp := field.NewPath("spec") 41 | 42 | BeforeEach(func() { 43 | }) 44 | 45 | Describe("Validate", func() { 46 | fmt.Printf(".") 47 | It("validate expected specs exist", func(done Done) { 48 | var e field.ErrorList 49 | e = gcsonly.Validate(fp, "storage", e, false, true, map[string]string{storage.FieldGCS: storage.Expected}) 50 | Expect(len(e)).To(Equal(0)) 51 | e = nfsonly.Validate(fp, "storage", e, false, true, map[string]string{storage.FieldNFS: storage.Expected}) 52 | Expect(len(e)).To(Equal(0)) 53 | e = both.Validate(fp, "storage", e, false, false, map[string]string{storage.FieldNFS: storage.Expected, storage.FieldGCS: storage.Expected}) 54 | Expect(len(e)).To(Equal(0)) 55 | close(done) 56 | }) 57 | It("validate missing expected specs", func(done Done) { 58 | var e field.ErrorList 59 | e = none.Validate(fp, "storage", e, false, false, map[string]string{storage.FieldNFS: storage.Expected}) 60 | //fmt.Printf("%s", e.ToAggregate().Error()) 61 | Expect(len(e)).To(Equal(2)) 62 | 63 | e = gcsonly.Validate(fp, "storage", e, false, true, map[string]string{storage.FieldNFS: storage.Expected}) 64 | //fmt.Printf("%s", e.ToAggregate().Error()) 65 | Expect(len(e)).To(Equal(5)) 66 | 67 | e = nfsonly.Validate(fp, "storage", e, false, true, map[string]string{storage.FieldGCS: storage.Expected}) 68 | //fmt.Printf("%s", e.ToAggregate().Error()) 69 | Expect(len(e)).To(Equal(8)) 70 | 71 | close(done) 72 | }) 73 | It("validate only one exist", func(done Done) { 74 | var e field.ErrorList 75 | e = nfsonly.Validate(fp, "storage", e, false, true, map[string]string{storage.FieldNFS: storage.Optional, storage.FieldGCS: storage.Optional}) 76 | Expect(len(e)).To(Equal(0)) 77 | 78 | e = both.Validate(fp, "storage", e, false, true, map[string]string{storage.FieldNFS: storage.Optional, storage.FieldGCS: storage.Optional}) 79 | //fmt.Printf("%s", e.ToAggregate().Error()) 80 | Expect(len(e)).To(Equal(1)) 81 | 82 | e = none.Validate(fp, "storage", e, false, true, map[string]string{storage.FieldNFS: storage.Optional, storage.FieldGCS: storage.Optional}) 83 | fmt.Printf("%s", e.ToAggregate().Error()) 84 | Expect(len(e)).To(Equal(2)) 85 | 86 | close(done) 87 | }) 88 | It("validate no storage spec errors", func(done Done) { 89 | var e field.ErrorList 90 | e = none.Validate(fp, "storage", e, true, false, map[string]string{storage.FieldNFS: storage.Optional, storage.FieldGCS: storage.Optional}) 91 | Expect(len(e)).To(Equal(0)) 92 | 93 | close(done) 94 | }) 95 | }) 96 | }) 97 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/storage/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package storage 15 | 16 | import ( 17 | corev1 "k8s.io/api/core/v1" 18 | ) 19 | 20 | // const fileds 21 | const ( 22 | FieldGCS = "gcs" 23 | FieldNFS = "nfs" 24 | FieldFS = "fs" 25 | 26 | Optional = "optional" 27 | Expected = "expected" 28 | ) 29 | 30 | // Spec is a generic cwspec to define a storage destination 31 | // +k8s:deepcopy-gen=true 32 | type Spec struct { 33 | GCS *GCS `json:"gcs,omitempty"` 34 | NFS *corev1.NFSVolumeSource `json:"nfs,omitempty"` 35 | FS *FS `json:"fs,omitempty"` 36 | } 37 | 38 | // GCS hold gcs related fields 39 | type GCS struct { 40 | // Bucket name 41 | Bucket string `json:"bucket,omitempty"` 42 | // Secret to access bucket 43 | Secret *corev1.SecretReference `json:"secret,omitempty"` 44 | // ReadOnly bool 45 | ReadOnly bool `json:"readonly,omitempty"` 46 | // Path name 47 | Path string `json:"path,omitempty"` 48 | } 49 | 50 | // FS hold filesystem related fields 51 | type FS struct { 52 | // Path name 53 | Path string `json:"path,omitempty"` 54 | } 55 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/storage/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | // +build !ignore_autogenerated 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one or more 4 | // contributor license agreements. See the NOTICE file distributed with 5 | // this work for additional information regarding copyright ownership. 6 | // The ASF licenses this file to You under the Apache License, Version 2.0 7 | // (the "License"); you may not use this file except in compliance with 8 | // the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | // Code generated by main. DO NOT EDIT. 19 | 20 | package storage 21 | 22 | import ( 23 | v1 "k8s.io/api/core/v1" 24 | ) 25 | 26 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 27 | func (in *FS) DeepCopyInto(out *FS) { 28 | *out = *in 29 | return 30 | } 31 | 32 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FS. 33 | func (in *FS) DeepCopy() *FS { 34 | if in == nil { 35 | return nil 36 | } 37 | out := new(FS) 38 | in.DeepCopyInto(out) 39 | return out 40 | } 41 | 42 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 43 | func (in *GCS) DeepCopyInto(out *GCS) { 44 | *out = *in 45 | if in.Secret != nil { 46 | in, out := &in.Secret, &out.Secret 47 | *out = new(v1.SecretReference) 48 | **out = **in 49 | } 50 | return 51 | } 52 | 53 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCS. 54 | func (in *GCS) DeepCopy() *GCS { 55 | if in == nil { 56 | return nil 57 | } 58 | out := new(GCS) 59 | in.DeepCopyInto(out) 60 | return out 61 | } 62 | 63 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 64 | func (in *Spec) DeepCopyInto(out *Spec) { 65 | *out = *in 66 | if in.GCS != nil { 67 | in, out := &in.GCS, &out.GCS 68 | *out = new(GCS) 69 | (*in).DeepCopyInto(*out) 70 | } 71 | if in.NFS != nil { 72 | in, out := &in.NFS, &out.NFS 73 | *out = new(v1.NFSVolumeSource) 74 | **out = **in 75 | } 76 | if in.FS != nil { 77 | in, out := &in.FS, &out.FS 78 | *out = new(FS) 79 | **out = **in 80 | } 81 | return 82 | } 83 | 84 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Spec. 85 | func (in *Spec) DeepCopy() *Spec { 86 | if in == nil { 87 | return nil 88 | } 89 | out := new(Spec) 90 | in.DeepCopyInto(out) 91 | return out 92 | } 93 | -------------------------------------------------------------------------------- /vendor/sigs.k8s.io/controller-reconciler/pkg/test/helper.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Google LLC 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package test 18 | 19 | import ( 20 | corev1 "k8s.io/api/core/v1" 21 | "k8s.io/apimachinery/pkg/api/resource" 22 | "os" 23 | "path/filepath" 24 | "strconv" 25 | ) 26 | 27 | // OpenFile - open file 28 | func OpenFile(path string) (*os.File, error) { 29 | path, err := filepath.Abs(path) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | f, err := os.Open(path) 35 | if err != nil { 36 | return nil, err 37 | } 38 | 39 | return f, nil 40 | } 41 | 42 | // AdjustCPU - increase/decrease cpu 43 | func AdjustCPU(r *corev1.ResourceRequirements, by int64) { 44 | newValue := r.Requests.Cpu().MilliValue() + by 45 | r.Requests[corev1.ResourceCPU] = *resource.NewMilliQuantity(newValue, resource.BinarySI) 46 | } 47 | 48 | // AddMemoryGB - increase Memory 49 | func AddMemoryGB(r *corev1.ResourceRequirements, req int, limit int) { 50 | mem := r.Requests[corev1.ResourceMemory] 51 | mmem := &mem 52 | add, _ := resource.ParseQuantity(strconv.Itoa(req) + "Gi") 53 | mmem.Add(add) 54 | r.Requests[corev1.ResourceMemory] = mem 55 | 56 | mem = r.Limits[corev1.ResourceMemory] 57 | mmem = &mem 58 | add, _ = resource.ParseQuantity(strconv.Itoa(limit) + "Gi") 59 | mmem.Add(add) 60 | r.Limits[corev1.ResourceMemory] = mem 61 | } 62 | 63 | //= corev1.ResourceList{ 64 | //corev1.ResourceCPU: *resource.NewMilliQuantity(newValue, resource.BinarySI), 65 | //corev1.ResourceMemory: *ng.Resources.Requests.Memory(), 66 | //} 67 | --------------------------------------------------------------------------------