Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

EVEREST-495 Add multi namespaces #283

Merged
merged 5 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ init: ## Install dependencies

install-operators: ## Install operators to k8s
../bin/everest install \
--namespace percona-everest-operators \
--skip-wizard \

test-cli: ## Run all tests
Expand Down
50 changes: 11 additions & 39 deletions cli-tests/tests/flow/all-operators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,26 @@ test.describe('Everest CLI install', async () => {
test('install all operators', async ({ page, cli, request }) => {
const verifyClusterResources = async () => {
await test.step('verify installed operators in k8s', async () => {
const perconaEverestPodsOut = await cli.exec('kubectl get pods --namespace=percona-everest');

await perconaEverestPodsOut.outContainsNormalizedMany([
'everest-operator-controller-manager',
]);

const out = await cli.exec('kubectl get pods --namespace=percona-everest-all');

await out.outContainsNormalizedMany([
'percona-xtradb-cluster-operator',
'percona-server-mongodb-operator',
'percona-postgresql-operator',
'everest-operator-controller-manager',
]);
});
};
const clusterName = `test-${faker.number.int()}`;

await test.step('run everest install command', async () => {
const out = await cli.everestExecSkipWizard(
`install --name=${clusterName} --namespace=percona-everest-all`,
`install --namespace=percona-everest-all`,
);

await out.assertSuccess();
Expand All @@ -64,7 +69,7 @@ test.describe('Everest CLI install', async () => {
await out.outContains(
'name: DISABLE_TELEMETRY\n value: "false"',
);
out = await cli.exec(`kubectl patch service everest --patch '{"spec": {"type": "LoadBalancer"}}' --namespace=percona-everest-all`)
out = await cli.exec(`kubectl patch service everest --patch '{"spec": {"type": "LoadBalancer"}}' --namespace=percona-everest`)

await out.assertSuccess();

Expand All @@ -81,59 +86,26 @@ test.describe('Everest CLI install', async () => {
'name: DISABLE_TELEMETRY\n value: "true"',
);
// check that the spec.type is not overrided
out = await cli.exec('kubectl get service/everest --namespace=percona-everest-all -o yaml');
out = await cli.exec('kubectl get service/everest --namespace=percona-everest -o yaml');
await out.outContains(
'type: LoadBalancer',
);
});
await test.step('run everest install command using a different namespace', async () => {
const install = await cli.everestExecSkipWizard(
`install --namespace=different-everest`,
);

await install.assertSuccess();

let out = await cli.exec('kubectl get clusterrolebinding everest-admin-cluster-role-binding -o yaml');
await out.assertSuccess();

await out.outContainsNormalizedMany([
'namespace: percona-everest-all',
'namespace: different-everest',
]);
await cli.everestExec('uninstall --namespace=different-everest --assume-yes');
// Check that uninstall will fail because there's no everest deployment
out = await cli.everestExec('uninstall --namespace=different-everest --assume-yes');
await out.outErrContainsNormalizedMany([
'no Everest deployment in different-everest namespace',
]);

});

await test.step('uninstall Everest', async () => {
let out = await cli.everestExec(
`uninstall --namespace=percona-everest-all --assume-yes`,
`uninstall --assume-yes`,
);

await out.assertSuccess();
// check that the deployment does not exist
out = await cli.exec('kubectl get deploy percona-everest -n percona-everest-all');
out = await cli.exec('kubectl get deploy percona-everest -n percona-everest');

await out.outErrContainsNormalizedMany([
'Error from server (NotFound): deployments.apps "percona-everest" not found',
]);

});

await test.step('uninstall Everest non existent namespace', async () => {
let out = await cli.everestExec(
`uninstall --namespace=not-exist --assume-yes`,
);

await out.outErrContainsNormalizedMany([
'namespace not-exist is not found',
]);

});

});
});
11 changes: 8 additions & 3 deletions cli-tests/tests/flow/mongodb-operator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ test.describe('Everest CLI install', async () => {
test('install only mongodb-operator', async ({ page, cli, request }) => {
const verifyClusterResources = async () => {
await test.step('verify installed operators in k8s', async () => {
const out = await cli.exec('kubectl get pods --namespace=percona-everest');
const perconaEverestPodsOut = await cli.exec('kubectl get pods --namespace=percona-everest');

await perconaEverestPodsOut.outContainsNormalizedMany([
'everest-operator-controller-manager',
]);

const out = await cli.exec('kubectl get pods --namespace=percona-everest-operators');

await out.outContainsNormalizedMany([
'percona-server-mongodb-operator',
'everest-operator-controller-manager',
]);

await out.outNotContains([
Expand All @@ -44,7 +49,7 @@ test.describe('Everest CLI install', async () => {

await test.step('run everest install command', async () => {
const out = await cli.everestExecSkipWizard(
`install --operator.mongodb=true --operator.postgresql=false --operator.xtradb-cluster=false --name=${clusterName}`,
`install --operator.mongodb=true --operator.postgresql=false --operator.xtradb-cluster=false --namespace=percona-everest-operators`,
);

await out.assertSuccess();
Expand Down
13 changes: 9 additions & 4 deletions cli-tests/tests/flow/pg-operator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ test.describe('Everest CLI install', async () => {
test('install only postgresql-operator', async ({ page, cli, request }) => {
const verifyClusterResources = async () => {
await test.step('verify installed operators in k8s', async () => {
const out = await cli.exec('kubectl get pods --namespace=percona-everest');
const perconaEverestPodsOut = await cli.exec('kubectl get pods --namespace=percona-everest');

await perconaEverestPodsOut.outContainsNormalizedMany([
'everest-operator-controller-manager',
]);

const out = await cli.exec('kubectl get pods --namespace=percona-everest-operators');

await out.outContainsNormalizedMany([
'percona-postgresql-operator',
'everest-operator-controller-manager',
]);

await out.outNotContains([
Expand All @@ -43,7 +48,7 @@ test.describe('Everest CLI install', async () => {

await test.step('run everest install command', async () => {
const out = await cli.everestExecSkipWizard(
`install --operator.mongodb=false --operator.postgresql=true --operator.xtradb-cluster=false --name=${clusterName}`,
`install --operator.mongodb=false --operator.postgresql=true --operator.xtradb-cluster=false --namespace=percona-everest-operators`,
);

await out.assertSuccess();
Expand All @@ -63,7 +68,7 @@ test.describe('Everest CLI install', async () => {
await operator.assertSuccess();

const out = await cli.everestExecSkipWizard(
`install --operator.mongodb=false --operator.postgresql=true --operator.xtradb-cluster=true --name=${clusterName}`,
`install --operator.mongodb=false --operator.postgresql=true --operator.xtradb-cluster=true --namespace=percona-everest-operators`,
);
const restartedOperator = await cli.exec(`kubectl -n percona-everest get po | grep everest|awk {'print $1'}`);
await restartedOperator.assertSuccess();
Expand Down
11 changes: 8 additions & 3 deletions cli-tests/tests/flow/pxc-operator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ test.describe('Everest CLI install', async () => {
test('install only xtradb-cluster-operator', async ({ page, cli, request }) => {
const verifyClusterResources = async () => {
await test.step('verify installed operators in k8s', async () => {
const out = await cli.exec('kubectl get pods --namespace=percona-everest');
const perconaEverestPodsOut = await cli.exec('kubectl get pods --namespace=percona-everest');

await perconaEverestPodsOut.outContainsNormalizedMany([
'everest-operator-controller-manager',
]);

const out = await cli.exec('kubectl get pods --namespace=percona-everest-operators');

await out.outContainsNormalizedMany([
'percona-xtradb-cluster-operator',
'everest-operator-controller-manager',
]);

await out.outNotContains([
Expand All @@ -44,7 +49,7 @@ test.describe('Everest CLI install', async () => {

await test.step('run everest install command', async () => {
const out = await cli.everestExecSkipWizard(
`install --operator.mongodb=false --operator.postgresql=false --operator.xtradb-cluster=true --name=${clusterName}`,
`install --operator.mongodb=false --operator.postgresql=false --operator.xtradb-cluster=true --namespace=percona-everest-operators`,
);

await out.assertSuccess();
Expand Down
2 changes: 1 addition & 1 deletion commands/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/percona/percona-everest-cli/commands/delete"
)

func newDeleteCmd(l *zap.SugaredLogger) *cobra.Command {
func newDeleteCmd(l *zap.SugaredLogger) *cobra.Command { //nolint:deadcode,unused
cmd := &cobra.Command{
Use: "delete",
}
Expand Down
19 changes: 3 additions & 16 deletions commands/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import (

func newInstallCmd(l *zap.SugaredLogger) *cobra.Command {
cmd := &cobra.Command{
Use: "install",
Use: "install",
Example: "everestctl install --namespace dev --namespace staging --namespace prod --operator.mongodb=true --operator.postgresql=true --operator.xtradb-cluster=true --skip-wizard",
Run: func(cmd *cobra.Command, args []string) {
initInstallViperFlags(cmd)
c := &install.Config{}
Expand Down Expand Up @@ -57,36 +58,22 @@ func newInstallCmd(l *zap.SugaredLogger) *cobra.Command {

func initInstallFlags(cmd *cobra.Command) {
cmd.Flags().StringP("kubeconfig", "k", "~/.kube/config", "Path to a kubeconfig")
cmd.Flags().StringP("name", "n", "", "Kubernetes cluster name")
cmd.Flags().String("namespace", "percona-everest", "Namespace into which Percona Everest components are deployed to")
cmd.Flags().StringArray("namespace", []string{}, "Namespaces list Percona Everest can manage")
cmd.Flags().Bool("skip-wizard", false, "Skip installation wizard")

cmd.Flags().Bool("operator.mongodb", true, "Install MongoDB operator")
cmd.Flags().Bool("operator.postgresql", true, "Install PostgreSQL operator")
cmd.Flags().Bool("operator.xtradb-cluster", true, "Install XtraDB Cluster operator")

cmd.Flags().String("channel.everest", "stable-v0", "Channel for Everest operator")
cmd.Flags().String("channel.victoria-metrics", "stable-v0", "Channel for VictoriaMetrics operator")
cmd.Flags().String("channel.xtradb-cluster", "stable-v1", "Channel for XtraDB Cluster operator")
cmd.Flags().String("channel.mongodb", "stable-v1", "Channel for MongoDB operator")
cmd.Flags().String("channel.postgresql", "fast-v2", "Channel for PostgreSQL operator")
}

func initInstallViperFlags(cmd *cobra.Command) {
viper.BindPFlag("skip-wizard", cmd.Flags().Lookup("skip-wizard")) //nolint:errcheck,gosec

viper.BindEnv("kubeconfig") //nolint:errcheck,gosec
viper.BindPFlag("kubeconfig", cmd.Flags().Lookup("kubeconfig")) //nolint:errcheck,gosec
viper.BindPFlag("name", cmd.Flags().Lookup("name")) //nolint:errcheck,gosec
viper.BindPFlag("namespace", cmd.Flags().Lookup("namespace")) //nolint:errcheck,gosec

viper.BindPFlag("operator.mongodb", cmd.Flags().Lookup("operator.mongodb")) //nolint:errcheck,gosec
viper.BindPFlag("operator.postgresql", cmd.Flags().Lookup("operator.postgresql")) //nolint:errcheck,gosec
viper.BindPFlag("operator.xtradb-cluster", cmd.Flags().Lookup("operator.xtradb-cluster")) //nolint:errcheck,gosec

viper.BindPFlag("channel.victoria-metrics", cmd.Flags().Lookup("channel.victoria-metrics")) //nolint:errcheck,gosec
viper.BindPFlag("channel.xtradb-cluster", cmd.Flags().Lookup("channel.xtradb-cluster")) //nolint:errcheck,gosec
viper.BindPFlag("channel.mongodb", cmd.Flags().Lookup("channel.mongodb")) //nolint:errcheck,gosec
viper.BindPFlag("channel.postgresql", cmd.Flags().Lookup("channel.postgresql")) //nolint:errcheck,gosec
viper.BindPFlag("channel.everest", cmd.Flags().Lookup("channel.everest")) //nolint:errcheck,gosec
}
34 changes: 0 additions & 34 deletions commands/monitoring.go

This file was deleted.

98 changes: 0 additions & 98 deletions commands/monitoring/enable.go

This file was deleted.

Loading
Loading