Skip to content

Commit 1a1d8e7

Browse files
authored
Add Kustomize File (#240)
1 parent b464100 commit 1a1d8e7

File tree

11 files changed

+26
-14
lines changed

11 files changed

+26
-14
lines changed

cmd/testrunner/crds/crds.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"io/ioutil"
77
"os"
8-
"path"
98
"path/filepath"
109
"strings"
1110

@@ -18,15 +17,15 @@ import (
1817
"k8s.io/client-go/rest"
1918
)
2019

21-
// EnsureCreation will locate all crd files "*_crd.yaml" in the given deploy directory and ensure that these
20+
// EnsureCreation will locate all crd files "*_crd.yaml" in the given crd directory and ensure that these
2221
// CRDs are created into the kubernetes cluster
23-
func EnsureCreation(config *rest.Config, deployDir string) error {
22+
func EnsureCreation(config *rest.Config, crdDir string) error {
2423
apiextensionsClientSet, err := apiextensionsclientset.NewForConfig(config)
2524
if err != nil {
2625
return errors.Errorf("error creating apiextensions client set: %s", err)
2726
}
2827

29-
crdFilePaths, err := allCrds(deployDir)
28+
crdFilePaths, err := allCrds(crdDir)
3029
if err != nil {
3130
return errors.Errorf("error walking deploy directory: %s", err)
3231
}
@@ -62,8 +61,7 @@ func marshalCRDFromYAMLBytes(bytes []byte, crd *apiextensionsv1beta1.CustomResou
6261
return json.Unmarshal(jsonBytes, &crd)
6362
}
6463

65-
func allCrds(deployDir string) ([]string, error) {
66-
crdDir := path.Join(deployDir, "crds")
64+
func allCrds(crdDir string) ([]string, error) {
6765
var crdFilePaths []string
6866
err := filepath.Walk(crdDir, func(path string, info os.FileInfo, err error) error {
6967
if info != nil && strings.HasSuffix(info.Name(), "_crd.yaml") {

cmd/testrunner/main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
type flags struct {
3434
deployDir string
35+
crdDir string
3536
namespace string
3637
operatorImage string
3738
versionUpgradeHookImage string
@@ -41,9 +42,10 @@ type flags struct {
4142
}
4243

4344
func parseFlags() flags {
44-
var namespace, deployDir, operatorImage, versionUpgradeHookImage, testImage, test, performCleanup *string
45+
var namespace, deployDir, crdDir, operatorImage, versionUpgradeHookImage, testImage, test, performCleanup *string
4546
namespace = flag.String("namespace", "default", "the namespace the operator and tests should be deployed in")
46-
deployDir = flag.String("deployDir", "deploy/", "the path to the directory which contains the yaml deployment files")
47+
deployDir = flag.String("deployDir", "deploy/operator/", "the path to the directory which contains the yaml deployment files")
48+
crdDir = flag.String("crdDir", "deploy/crds/", "the path to the directory which contains the yaml crd files")
4749
operatorImage = flag.String("operatorImage", "quay.io/mongodb/community-operator-dev:latest", "the image which should be used for the operator deployment")
4850
versionUpgradeHookImage = flag.String("versionUpgradeHookImage", "quay.io/mongodb/community-operator-pre-stop-hook:latest", "the version upgrade post-start hook image")
4951
testImage = flag.String("testImage", "quay.io/mongodb/community-operator-e2e:latest", "the image which should be used for the operator e2e tests")
@@ -53,6 +55,7 @@ func parseFlags() flags {
5355

5456
return flags{
5557
deployDir: *deployDir,
58+
crdDir: *crdDir,
5659
namespace: *namespace,
5760
operatorImage: *operatorImage,
5861
versionUpgradeHookImage: *versionUpgradeHookImage,
@@ -87,7 +90,7 @@ func runCmd(f flags) error {
8790

8891
fmt.Printf("Ensured namespace: %s\n", f.namespace)
8992

90-
if err := crds.EnsureCreation(config, f.deployDir); err != nil {
93+
if err := crds.EnsureCreation(config, f.crdDir); err != nil {
9194
return errors.Errorf("could not ensure CRDs: %s", err)
9295
}
9396

deploy/kustomization.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- ./crds/mongodb.com_mongodb_crd.yaml
5+
- ./operator/service_account.yaml
6+
- ./operator/role.yaml
7+
- ./operator/role_binding.yaml
8+
- ./operator/operator.yaml
9+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/deploy-configure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ If you want to deploy the operator on OpenShift you will have to provide the env
4242

4343
See [here](../deploy/crds/mongodb.com_v1_mongodb_openshift_cr.yaml) for an example of how to provide the required configuration for a MongoDB ReplicaSet.
4444

45-
See [here](../deploy/operator_openshift.yaml) for an example of how to configure the Operator deployment.
45+
See [here](../deploy/openshift/operator_openshift.yaml) for an example of how to configure the Operator deployment.
4646

4747
### Example
4848

docs/install-upgrade.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ To install the MongoDB Community Kubernetes Operator:
4242
4343
a. Invoke the following `kubectl` command to install the Operator in the specified namespace:
4444
```
45-
kubectl create -f deploy/ --namespace <my-namespace>
45+
kubectl create -f deploy/operator/ --namespace <my-namespace>
4646
```
4747
b. Verify that the Operator installed successsfully:
4848
```

scripts/dev/build_and_deploy_operator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616

1717
def _load_operator_service_account() -> Dict:
18-
return load_yaml_from_file("deploy/service_account.yaml")
18+
return load_yaml_from_file("deploy/operator/service_account.yaml")
1919

2020

2121
def _load_operator_role() -> Dict:
22-
return load_yaml_from_file("deploy/role.yaml")
22+
return load_yaml_from_file("deploy/operator/role.yaml")
2323

2424

2525
def _load_operator_role_binding() -> Dict:
26-
return load_yaml_from_file("deploy/role_binding.yaml")
26+
return load_yaml_from_file("deploy/operator/role_binding.yaml")
2727

2828

2929
def _load_operator_deployment(operator_image: str) -> Dict:

0 commit comments

Comments
 (0)