Skip to content

Commit

Permalink
mimprovments indocumentation and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rchakode committed Mar 18, 2024
1 parent 1798853 commit 991bba0
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 25 deletions.
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

---

<!-- vscode-markdown-toc -->
<!-- vscode-markdown-tkubectl -->
- [What is Krossboard Kubernetes Operator](#what-is-krossboard-kubernetes-operator)
- [Deploy Krossboard Kubernetes Operator](#deploy-krossboard-kubernetes-operator)
- [Deploy a Krossboard Instance](#deploy-a-krossboard-instance)
Expand All @@ -16,7 +16,7 @@
numbering=false
autoSave=true
/vscode-markdown-toc-config -->
<!-- /vscode-markdown-toc -->
<!-- /vscode-markdown-tkubectl -->

# What is Krossboard Kubernetes Operator

Expand Down Expand Up @@ -44,26 +44,40 @@ kubectl apply -f https://raw.githubusercontent.com/2-alchemists/krossboard-kuber

The installation is achieved in a namespace named `krossboard`.


# <a name='DeployaKrossboardInstance'></a>Deploy a Krossboard Instance

## <a name='CreateaKrossboardCR'></a>Create a Krossboard CR

Once the operator deployed, a custom resource named `Krossboard` is created. This CR is used to define each instance of Krossboard.

See [krossboard.yaml](https://github.com/2-alchemists/krossboard-kubernetes-operator/blob/main/config/releases/latest/krossboard/krossboard.yaml) for an example of Krossboard instance
See [krossboard.yaml](https://github.com/2-alchemists/krossboard-kubernetes-operator/blob/main/config/releases/latest/krossboard/krossboard.yaml) for an example to a Krossboard instance along with its persistent volume claim.

```yaml
---
apiVersion: krossboard.krossboard.app/v1alpha1
kind: Krossboard
metadata:
name: krossboard
namespace: krossboard
spec:
koaImage: rchakode/kube-opex-analytics:22.12.0
koaImage: rchakode/kube-opex-analytics:24.03.3
krossboardDataProcessorImage: krossboard/krossboard-data-processor:1.3.0
krossboardUIImage: krossboard/krossboard-ui:1.2.0-49b2666
krossboardPersistentVolumeClaim: krossboard-data-pvc
krossboardSecretName: krossboard-secrets
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: krossboard-data-pvc
namespace: krossboard
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
# storageClassName: uncomment-and-set-if-not-using-default
```

Each instance of Krossboard allows to track the usage of a set of Kubernetes clusters listed in a KUBECONFIG secret.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ metadata:
name: krossboard
namespace: krossboard
spec:
koaImage: rchakode/kube-opex-analytics:22.12.0
koaImage: rchakode/kube-opex-analytics:24.03.3
krossboardDataProcessorImage: krossboard/krossboard-data-processor:1.3.0
krossboardPersistentVolumeClaim: krossboard-data-pvc
krossboardSecretName: krossboard-secrets
Expand Down
2 changes: 1 addition & 1 deletion config/releases/latest/krossboard/krossboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Krossboard
metadata:
name: krossboard
spec:
koaImage: rchakode/kube-opex-analytics:22.12.0
koaImage: rchakode/kube-opex-analytics:24.03.3
krossboardDataProcessorImage: krossboard/krossboard-data-processor:1.3.0
krossboardUIImage: krossboard/krossboard-ui:1.2.1
krossboardPersistentVolumeClaim: krossboard-data-pvc
Expand Down
4 changes: 2 additions & 2 deletions docs/create-kubeconfig-secret.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ This page provides a general guide to create a secret based on one or more KUBEC

When you have several KUBECONFIG resources, the idea of the procedure described hereafyer is to create a merged version before creating the secret.

First, set an environment variable with a comma-seperated list of KUBECONFIG files.
First, set an environment variable with a colon-seperated list of KUBECONFIG files.

```bash
export KB_KUBECONFIG=/path/to/kubeconfig1;/path/to/kubeconfig2;...
export KB_KUBECONFIG=/path/to/kubeconfig1:/path/to/kubeconfig2:...
```

Generate a secret file with the resulting KUBECONFIG.
Expand Down
26 changes: 12 additions & 14 deletions docs/create-kubeconfig-with-minimal-permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Create KUBECONFIG wih Minimal Permissions for Krossboard

<!-- vscode-markdown-toc -->
<!-- vscode-markdown-tkubectl -->
- [Create KUBECONFIG wih Minimal Permissions for Krossboard](#create-kubeconfig-wih-minimal-permissions-for-krossboard)
- [Overview](#overview)
- [Create RBAC Resources (Service Account, ClusterRole, ClusterRoleBinding)](#create-rbac-resources-service-account-clusterrole-clusterrolebinding)
Expand All @@ -15,7 +15,7 @@
numbering=false
autoSave=true
/vscode-markdown-toc-config -->
<!-- /vscode-markdown-toc -->
<!-- /vscode-markdown-tkubectl -->

## <a name='Overview'></a>Overview
This document describes step-by-step how to create a KUBECONFIG resource with minimal RBAC permissions for Krossboard.
Expand Down Expand Up @@ -46,9 +46,7 @@ The created RBAC resources include the following:
The following command outputs the token associated to the service account `kube-opex-analytics`.

```bash
kubectl -n kube-opex-analytics get secret \
$(kubectl -n kube-opex-analytics get sa kube-opex-analytics -ojsonpath='{.secrets[0].name}') \
-ojsonpath='{.data.token}' | base64 -d
kubectl -n kube-opex-analytics get secret kube-opex-analytics -ojsonpath='{.data.token}' | base64 -d
```


Expand All @@ -67,20 +65,20 @@ Make sure to update the following parameters:
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: <cluster-cacert>
server: https://your-k8s-cluster-api:6443
name: <cluster-name>
certificate-authority-data: <K8s-CLUSTER-CACERT>
server: https://K8s-CLUSTER-API:6443
name: <K8s-CLUSTER-NAME>
contexts:
- context:
cluster: <cluster-name>
user: <cluster-name>_serviceaccount_kube-opex-analytics
name: <cluster-name>
current-context: <cluster-name>
cluster: <K8s-CLUSTER-NAME>
user: <K8s-CLUSTER-NAME>_serviceaccount_kube-opex-analytics
name: <K8s-CLUSTER-NAME>
current-context: <K8s-CLUSTER-NAME>
kind: Config
preferences: {}
users:
- name: <cluster-name>_serviceaccount_kube-opex-analytics
- name: <K8s-CLUSTER-NAME>_serviceaccount_kube-opex-analytics
user:
token: <service-account-token-here>
token: <KUBE-OPEX-ANALYTICS-SERVICE-ACCOUNT-TOKEN>
```
4 changes: 2 additions & 2 deletions test-freshdeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ make build docker-build docker-push
make deploy

# get SA token
# oc -n kube-opex-analytics get secret $(oc -n kube-opex-analytics get sa kube-opex-analytics -ojsonpath='{.secrets[0].name}') -ojsonpath='{.data.token}' | base64 -d > token
# kubectl -n kube-opex-analytics get secret $(kubectl -n kube-opex-analytics get sa kube-opex-analytics -ojsonpath='{.secrets[0].name}') -ojsonpath='{.data.token}' | base64 -d > token

export KB_KUBECONFIG=/home/codespace/.kube/config-sa-token
kubectl -n krossboard \
Expand All @@ -21,6 +21,6 @@ kubectl -n krossboard \

kubectl apply -f krossboard-secrets.yaml

oc apply -k config/latest/
kubectl apply -k config/latest/

docker system prune -f -a

0 comments on commit 991bba0

Please sign in to comment.