Skip to content

Commit a13b8eb

Browse files
author
psaini
committed
Added Oracle-Database-Operator files from the release-0.1.0 branch and initialized the repo with code and README.md
1 parent 09cc2c0 commit a13b8eb

File tree

150 files changed

+27561
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+27561
-0
lines changed

CONTRIBUTING.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Contributing to This Repository
2+
3+
We welcome your contributions! There are multiple ways to contribute.
4+
5+
## Opening issues
6+
7+
For bugs or enhancement requests, please file a GitHub issue unless the problem is security-related. When filing a bug, remember that the more specific the bug is, the more likely it is to be fixed. If you think you've found a security
8+
vulnerability, then do not raise a GitHub issue. Instead, follow the instructions in our
9+
[security policy](./SECURITY.md).
10+
11+
## Contributing code
12+
13+
We welcome your code contributions. Before submitting code by using a pull request,
14+
you must sign the [Oracle Contributor Agreement][OCA] (OCA), and your commits must include the following line, using the name and e-mail address you used to sign the OCA:
15+
16+
```text
17+
Signed-off-by: Your Name <[email protected]>
18+
```
19+
20+
You can add this line automatically to pull requests by committing with `--sign-off`
21+
or `-s`. For example:
22+
23+
```text
24+
git commit --signoff
25+
```
26+
27+
Only pull requests from committers that can be verified as having signed the OCA
28+
can be accepted.
29+
30+
## Pull request process
31+
32+
1. Ensure there is an issue created to track and discuss the fix or enhancement that you intend to submit.
33+
1. Fork this repository.
34+
1. Create a branch in your fork to implement the changes. Oracle recommends using
35+
the issue number as part of your branch name. For example: `1234-fixes`
36+
1. Ensure that any documentation is updated with the changes that are required
37+
by your change.
38+
1. Ensure that any samples are updated, if the base image has been changed.
39+
1. Submit the pull request. *Do not leave the pull request blank*. Explain exactly
40+
what your changes are meant to do, and provide simple steps to indicate how to validate
41+
your changes. Ensure that you reference the issue that you created as well.
42+
1. Before the changes are merged, Oracle will assign the pull request to 2 or 3 people for review.
43+
44+
## Code of conduct
45+
46+
Follow the [Golden Rule](https://en.wikipedia.org/wiki/Golden_Rule). If you'd
47+
like more specific guidelines, see the [Contributor Covenant Code of Conduct][COC].
48+
49+
[OCA]: https://oca.opensource.oracle.com
50+
[COC]: https://www.contributor-covenant.org/version/1/4/code-of-conduct/

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (c) 2021, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
#
4+
5+
# Build the manager binary
6+
FROM golang:1.16 as builder
7+
8+
WORKDIR /workspace
9+
# Copy the Go Modules manifests
10+
COPY go.mod go.mod
11+
COPY go.sum go.sum
12+
# cache deps before building and copying source so that we don't need to re-download as much
13+
# and so that source changes don't invalidate our downloaded layer
14+
RUN go mod download
15+
16+
# Copy the go source
17+
COPY main.go main.go
18+
COPY apis/ apis/
19+
COPY controllers/ controllers/
20+
COPY commons/ commons/
21+
COPY LICENSE.txt LICENSE.txt
22+
COPY THIRD_PARTY_LICENSES_DOCKER.txt THIRD_PARTY_LICENSES_DOCKER.txt
23+
24+
# Build
25+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
26+
27+
# Use oraclelinux:8-slim as base image to package the manager binary
28+
FROM oraclelinux:8-slim
29+
WORKDIR /
30+
COPY --from=builder /workspace/manager .
31+
RUN useradd -u 1002 nonroot
32+
USER nonroot
33+
34+
ENTRYPOINT ["/manager"]

LICENSE.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2021 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.

Makefile

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
#
2+
# Copyright (c) 2021, Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
#
5+
6+
# Current Operator version
7+
VERSION ?= 0.0.1
8+
# Default bundle image tag
9+
BUNDLE_IMG ?= controller-bundle:$(VERSION)
10+
# Options for 'bundle-build'
11+
ifneq ($(origin CHANNELS), undefined)
12+
BUNDLE_CHANNELS := --channels=$(CHANNELS)
13+
endif
14+
ifneq ($(origin DEFAULT_CHANNEL), undefined)
15+
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
16+
endif
17+
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
18+
19+
# Image URL to use all building/pushing image targets
20+
IMG ?= controller:latest
21+
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
22+
# API version has to be v1 to use defaulting (https://github.com/kubernetes-sigs/controller-tools/issues/478)
23+
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
24+
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
25+
ENVTEST_K8S_VERSION = 1.21
26+
27+
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
28+
ifeq (,$(shell go env GOBIN))
29+
GOBIN=$(shell go env GOPATH)/bin
30+
else
31+
GOBIN=$(shell go env GOBIN)
32+
endif
33+
34+
# Setting SHELL to bash allows bash commands to be executed by recipes.
35+
# This is a requirement for 'setup-envtest.sh' in the test target.
36+
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
37+
SHELL = /usr/bin/env bash -o pipefail
38+
.SHELLFLAGS = -ec
39+
40+
all: build
41+
42+
##@ Development
43+
44+
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
45+
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
46+
47+
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
48+
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
49+
50+
fmt: ## Run go fmt against code.
51+
go fmt ./...
52+
53+
vet: ## Run go vet against code.
54+
go vet ./...
55+
56+
TEST ?= ./apis/... ./commons/... ./controllers/...
57+
test: manifests generate fmt vet envtest ## Run unit tests.
58+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test $(TEST) -coverprofile cover.out
59+
60+
E2ETEST ?= ./test/e2e/
61+
e2e: manifests generate fmt vet envtest ## Run e2e tests.
62+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test $(E2ETEST) -v -timeout 40m -ginkgo.v -ginkgo.failFast
63+
64+
##@ Build
65+
66+
build: generate fmt vet ## Build manager binary.
67+
go build -o bin/manager main.go
68+
69+
run: manifests generate fmt vet ## Run a controller from your host.
70+
go run ./main.go
71+
72+
docker-build: test ## Build docker image with the manager.
73+
docker build --no-cache=true --build-arg http_proxy=${HTTP_PROXY} --build-arg https_proxy=${HTTPS_PROXY} . -t ${IMG}
74+
75+
#docker-build-proxy: test
76+
# docker build --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} build . -t ${IMG}
77+
78+
docker-push: ## Push docker image with the manager.
79+
docker push ${IMG}
80+
81+
##@ Deployment
82+
83+
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
84+
$(KUSTOMIZE) build config/crd | kubectl apply -f -
85+
86+
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
87+
$(KUSTOMIZE) build config/crd | kubectl delete -f -
88+
89+
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
90+
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
91+
$(KUSTOMIZE) build config/default | kubectl apply -f -
92+
93+
operator-yaml: manifests kustomize
94+
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
95+
$(KUSTOMIZE) build config/default > $$(basename $$(pwd)).yaml
96+
97+
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
98+
$(KUSTOMIZE) build config/default | kubectl delete -f -
99+
100+
101+
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
102+
controller-gen: ## Download controller-gen locally if necessary.
103+
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])
104+
105+
KUSTOMIZE = $(shell pwd)/bin/kustomize
106+
kustomize: ## Download kustomize locally if necessary.
107+
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected])
108+
109+
ENVTEST = $(shell pwd)/bin/setup-envtest
110+
envtest: ## Download envtest-setup locally if necessary.
111+
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
112+
113+
# go-get-tool will 'go get' any package $2 and install it to $1.
114+
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
115+
define go-get-tool
116+
@[ -f $(1) ] || { \
117+
set -e ;\
118+
TMP_DIR=$$(mktemp -d) ;\
119+
cd $$TMP_DIR ;\
120+
go mod init tmp ;\
121+
echo "Downloading $(2)" ;\
122+
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
123+
rm -rf $$TMP_DIR ;\
124+
}
125+
endef
126+
127+
.PHONY: bundle
128+
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
129+
operator-sdk generate kustomize manifests -q
130+
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
131+
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
132+
operator-sdk bundle validate ./bundle
133+
134+
.PHONY: bundle-build
135+
bundle-build: ## Build the bundle image.
136+
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
137+
138+
.PHONY: bundle-push
139+
bundle-push: ## Push the bundle image.
140+
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
141+
142+
.PHONY: opm
143+
OPM = ./bin/opm
144+
opm: ## Download opm locally if necessary.
145+
ifeq (,$(wildcard $(OPM)))
146+
ifeq (,$(shell which opm 2>/dev/null))
147+
@{ \
148+
set -e ;\
149+
mkdir -p $(dir $(OPM)) ;\
150+
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
151+
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$${OS}-$${ARCH}-opm ;\
152+
chmod +x $(OPM) ;\
153+
}
154+
else
155+
OPM = $(shell which opm)
156+
endif
157+
endif
158+
159+
# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
160+
# These images MUST exist in a registry and be pull-able.
161+
BUNDLE_IMGS ?= $(BUNDLE_IMG)
162+
163+
# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
164+
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION)
165+
166+
# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
167+
ifneq ($(origin CATALOG_BASE_IMG), undefined)
168+
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
169+
endif
170+
171+
# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
172+
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
173+
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
174+
.PHONY: catalog-build
175+
catalog-build: opm ## Build a catalog image.
176+
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
177+
178+
# Push the catalog image.
179+
.PHONY: catalog-push
180+
catalog-push: ## Push a catalog image.
181+
$(MAKE) docker-push IMG=$(CATALOG_IMG)

PREREQUISITES.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
3+
## Prerequisites for Using Oracle Database Operator for Kubernetes
4+
5+
Oracle Database operator for Kubernetes (OraOperator) manages all Cloud deployments of Oracle Database, including:
6+
7+
* Oracle Autonomous Database (ADB)
8+
* Containerized Oracle Database Single Instance (SIDB)
9+
* Containerized Sharded Oracle Database (SHARDING)
10+
11+
### Setting Up a Kubernetes Cluster and Volumes
12+
13+
#### Setting Up an OKE Cluster on Oracle Cloud Infrastructure (OCI)
14+
15+
To set up a Kubernetes cluster on Oracle Cloud Infrastructure:
16+
17+
1. Log in to OCI
18+
1. Create an OKE Cluster
19+
1. Provision persistent storage for data files (NFS or Block)
20+
21+
Note: You must provision persistent storage if you intend to deploy containerized databases over the OKE cluster.
22+
23+
### Prerequites for Oracle Autonomous Database (ADB)
24+
25+
If you intent to use `OraOperator` to handle Oracle Autonomous Database lifecycles, then read [Oracle Autonomous Database prerequisites](./doc/adb/ADB_PREREQUISITES.md)
26+
27+
### Prerequites for Single Instance Databases (SIDB)
28+
29+
If you intent to use `OraOperator` to handle Oracle Database Single Instance lifecycles, then read [Single Instance Database Prerequisites](./doc/sidb/SIDB_PREREQUISITES.md)
30+
31+
### Prerequites for Sharded Databases (SHARDING)
32+
33+
If you intent to use OraOperator to handle the lifecycle of Oracle Database deployed with Oracle Sharding, then read [Sharded Database Prerequisites](./doc/sharding/ORACLE_SHARDING_CONTROLLER_README.md#prerequsites-for-running-oracle-sharding-database-controller)

PROJECT

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
domain: oracle.com
2+
layout:
3+
- go.kubebuilder.io/v2
4+
multigroup: true
5+
plugins:
6+
go.sdk.operatorframework.io/v2-alpha: {}
7+
projectName: oracle-database-operator
8+
repo: github.com/oracle/oracle-database-operator
9+
resources:
10+
- api:
11+
crdVersion: v1
12+
namespaced: true
13+
controller: true
14+
domain: oracle.com
15+
group: database
16+
kind: AutonomousDatabase
17+
path: github.com/oracle/oracle-database-operator/apis/database/v1alpha1
18+
version: v1alpha1
19+
- api:
20+
crdVersion: v1
21+
namespaced: true
22+
controller: true
23+
domain: oracle.com
24+
group: database
25+
kind: SingleInstanceDatabase
26+
path: github.com/oracle/oracle-database-operator/apis/database/v1alpha1
27+
version: v1alpha1
28+
webhooks:
29+
defaulting: true
30+
validation: true
31+
webhookVersion: v1
32+
- api:
33+
crdVersion: v1
34+
namespaced: true
35+
controller: true
36+
domain: oracle.com
37+
group: database
38+
kind: ShardingDatabase
39+
path: github.com/oracle/oracle-database-operator/apis/database/v1alpha1
40+
version: v1alpha1
41+
version: "3"

0 commit comments

Comments
 (0)