-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c85373
commit 1cfd0cd
Showing
11 changed files
with
1,257 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
analytics: | ||
disable: true | ||
|
||
rbac: | ||
create: true | ||
rules: | ||
- apiGroups: [ "*" ] | ||
resources: [ "*" ] | ||
verbs: [ "get", "watch", "list" ] # defaults | ||
staticGroupName: "botkube-plugins-default" | ||
|
||
extraObjects: | ||
|
||
# Group 'kubectl-first-channel': permissions for kubectl for first channel | ||
## namespace scoped permissions | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: &kubectl-wait | ||
name: kubectl-first-channel-namespaced-perms | ||
labels: | ||
app.kubernetes.io/instance: botkube-e2e-test | ||
rules: | ||
- apiGroups: [ "apps" ] | ||
resources: [ "deployments" ] | ||
verbs: [ "get","watch","list" ] | ||
- apiGroups: [ "" ] | ||
resources: [ "configmaps", "pods" ] | ||
verbs: [ "get", "watch", "list" ] | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
<<: *kubectl-wait | ||
namespace: botkube | ||
roleRef: &kubectl-wait-role | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: kubectl-first-channel-namespaced-perms | ||
subjects: &kubectl-first-channel-subject | ||
- kind: User | ||
name: kubectl-first-channel | ||
apiGroup: rbac.authorization.k8s.io | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
<<: *kubectl-wait | ||
namespace: default | ||
roleRef: *kubectl-wait-role | ||
subjects: *kubectl-first-channel-subject | ||
|
||
### cluster permissions | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: &kubectl-deploy-all-meta | ||
name: kc-first-channel-cluster-perms | ||
labels: | ||
app.kubernetes.io/instance: botkube-e2e-test | ||
rules: | ||
- apiGroups: [ "apps" ] | ||
resources: [ "deployments" ] | ||
verbs: [ "get", "list" ] | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: *kubectl-deploy-all-meta | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: kc-first-channel-cluster-perms | ||
subjects: *kubectl-first-channel-subject | ||
|
||
# Group 'kc-exec-only' | ||
## exec only for default and botkube namespaces: | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: &kc-exec-only-meta | ||
name: kc-exec-only | ||
labels: | ||
app.kubernetes.io/instance: botkube-e2e-test | ||
rules: | ||
- apiGroups: [ "" ] | ||
resources: [ "pods/exec" ] | ||
verbs: [ "create" ] | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
<<: *kc-exec-only-meta | ||
namespace: botkube | ||
roleRef: &kc-exec-only-role | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: kc-exec-only | ||
subjects: &kc-exec-only-subject | ||
- kind: User | ||
name: kc-exec-only | ||
apiGroup: rbac.authorization.k8s.io | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
<<: *kc-exec-only-meta | ||
namespace: default | ||
roleRef: *kc-exec-only-role | ||
subjects: *kc-exec-only-subject | ||
|
||
# Group 'kc-label-svc-all': | ||
## namespace scoped permissions | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: &kc-label-svc-all-meta | ||
name: kc-label-svc-all | ||
labels: | ||
app.kubernetes.io/instance: botkube-e2e-test | ||
rules: | ||
- apiGroups: [ "" ] | ||
resources: [ "services" ] | ||
verbs: [ "get", "patch" ] | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: *kc-label-svc-all-meta | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: kc-label-svc-all | ||
subjects: | ||
- kind: User | ||
name: kc-label-svc-all | ||
apiGroup: rbac.authorization.k8s.io | ||
|
||
# Group 'rbac-with-static-mapping': | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: &k8s-cm-watch-meta | ||
name: kc-watch-cm | ||
labels: | ||
app.kubernetes.io/instance: botkube-e2e-test | ||
rules: | ||
- apiGroups: [ "" ] | ||
resources: [ "configmaps" ] | ||
verbs: [ "watch", "list" ] | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: *k8s-cm-watch-meta | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: kc-watch-cm | ||
subjects: | ||
- kind: Group | ||
name: kc-watch-cm | ||
apiGroup: rbac.authorization.k8s.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package botkubex | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type InstallParams struct { | ||
BinaryPath string | ||
HelmRepoDirectory string | ||
ConfigProviderEndpoint string | ||
ConfigProviderIdentifier string | ||
ConfigProviderAPIKey string | ||
ImageRegistry string | ||
ImageRepository string | ||
ImageTag string | ||
PluginRestartPolicyThreshold int | ||
PluginRestartHealthCheckIntervalSeconds int | ||
} | ||
|
||
func Install(t *testing.T, params InstallParams) error { | ||
//nolint:gosec // this is not production code | ||
cmd := exec.Command(params.BinaryPath, "install", | ||
"--auto-approve", | ||
"--verbose", | ||
fmt.Sprintf("--repo=%s", params.HelmRepoDirectory), | ||
fmt.Sprintf("--values=%s/botkube/e2e-cloud-test-values.yaml", params.HelmRepoDirectory), | ||
`--version=""`, // installer doesn't call Helm repo`index.yaml` when version is empty, so local Helm chart works as expected. | ||
"--set", | ||
fmt.Sprintf("image.registry=%s", params.ImageRegistry), | ||
"--set", | ||
fmt.Sprintf("image.repository=%s", params.ImageRepository), | ||
"--set", | ||
fmt.Sprintf("image.tag=%s", params.ImageTag), | ||
"--set", | ||
fmt.Sprintf("config.provider.endpoint=%s", params.ConfigProviderEndpoint), | ||
"--set", | ||
fmt.Sprintf("config.provider.identifier=%s", params.ConfigProviderIdentifier), | ||
"--set", | ||
fmt.Sprintf("extraEnv[0].name=%s", "BOTKUBE_PLUGINS_RESTART__POLICY_THRESHOLD"), | ||
"--set-string", | ||
fmt.Sprintf("extraEnv[0].value=%d", params.PluginRestartPolicyThreshold), | ||
"--set", | ||
fmt.Sprintf("extraEnv[1].name=%s", "BOTKUBE_PLUGINS_HEALTH__CHECK__INTERVAL"), | ||
"--set-string", | ||
fmt.Sprintf("extraEnv[1].value=%ds", params.PluginRestartHealthCheckIntervalSeconds), | ||
"--set", | ||
fmt.Sprintf("config.provider.apiKey=%s", params.ConfigProviderAPIKey)) | ||
t.Logf("Executing command: %s", cmd.String()) | ||
cmd.Env = os.Environ() | ||
|
||
o, err := cmd.CombinedOutput() | ||
t.Logf("CLI output:\n%s", string(o)) | ||
return err | ||
} | ||
|
||
func Uninstall(t *testing.T, binaryPath string) { | ||
//nolint:gosec // this is not production code | ||
cmd := exec.Command(binaryPath, "uninstall", "--release-name", "botkube", "--namespace", "botkube", "--auto-approve") | ||
cmd.Env = os.Environ() | ||
|
||
o, err := cmd.CombinedOutput() | ||
t.Logf("CLI output:\n%s", string(o)) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.