Skip to content

Commit

Permalink
docs: custom kubeconfigs on checks & topology lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Oct 9, 2024
1 parent 7e3c014 commit 9ea55f8
Show file tree
Hide file tree
Showing 4 changed files with 340 additions and 8 deletions.
121 changes: 121 additions & 0 deletions canary-checker/docs/reference/1-kubernetes-resource.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,127 @@ check would be to see if a service is accessible via the ingress as shown in the
]}
/>

### Remote clusters

A single canary-checker instance can connect to any number of remote clusters via custom kubeconfig.
Either the kubeconfig itself or the path to the kubeconfig can be provided.

#### kubeconfig from kubernetes secret

```yaml title="remote-cluster.yaml" {11-15}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: pod-creation-test
spec:
schedule: "@every 5m"
kubernetesResource:
- name: pod creation on aws cluster
namespace: default
description: "deploy httpbin"
kubeconfig:
valueFrom:
secretKeyRef:
name: aws-kubeconfig
key: kubeconfig
resources:
- apiVersion: v1
kind: Pod
metadata:
name: httpbin
namespace: default
labels:
app: httpbin
spec:
containers:
- name: httpbin
image: "kennethreitz/httpbin:latest"
ports:
- containerPort: 80
```
#### Kubeconfig inline
```yaml title="remote-cluster.yaml" {11-32}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: pod-creation-test
spec:
schedule: "@every 5m"
kubernetesResource:
- name: pod creation on aws cluster
namespace: default
description: "deploy httpbin"
kubeconfig:
value: |
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: xxxxx
server: https://xxxxx.sk1.eu-west-1.eks.amazonaws.com
name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
contexts:
- context:
cluster: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
namespace: mission-control
user: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
current-context: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
kind: Config
preferences: {}
users:
- name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
user:
exec:
....
resources:
- apiVersion: v1
kind: Pod
metadata:
name: httpbin
namespace: default
labels:
app: httpbin
spec:
containers:
- name: httpbin
image: "kennethreitz/httpbin:latest"
ports:
- containerPort: 80
```
#### Kubeconfig from local filesystem
```yaml title="remote-cluster.yaml" {11-12}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: pod-creation-test
spec:
schedule: "@every 5m"
kubernetesResource:
- name: pod creation on aws cluster
namespace: default
description: "deploy httpbin"
kubeconfig:
value: /root/.kube/aws-kubeconfig
resources:
- apiVersion: v1
kind: Pod
metadata:
name: httpbin
namespace: default
labels:
app: httpbin
spec:
containers:
- name: httpbin
image: "kennethreitz/httpbin:latest"
ports:
- containerPort: 80
```
### Templating
The `resources` and `staticResources` fields can be templated using <CommonLink to="gotemplate">Go Templates</CommonLink>.
Expand Down
90 changes: 90 additions & 0 deletions canary-checker/docs/reference/1-kubernetes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,93 @@ dyn(results).all(x, k8s.isReady(x))
```
</div>
</details>


### Remote clusters

A single canary-checker instance can connect to any number of remote clusters via custom kubeconfig.
Either the kubeconfig itself or the path to the kubeconfig can be provided.

#### kubeconfig from kubernetes secret

```yaml title="remote-cluster.yaml" {11-15}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: pod-creation-test
spec:
schedule: "@every 5m"
kubernetes:
- name: pod creation on aws cluster
namespace: default
description: "deploy httpbin"
kubeconfig:
valueFrom:
secretKeyRef:
name: aws-kubeconfig
key: kubeconfig
kind: Pod
ready: true
namespaceSelector:
name: default
```
#### Kubeconfig inline
```yaml title="remote-cluster.yaml" {10-31}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: pod-creation-test
spec:
schedule: "@every 5m"
kubernetes:
- name: pod creation on aws cluster
namespace: default
kubeconfig:
value: |
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: xxxxx
server: https://xxxxx.sk1.eu-west-1.eks.amazonaws.com
name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
contexts:
- context:
cluster: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
namespace: mission-control
user: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
current-context: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
kind: Config
preferences: {}
users:
- name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
user:
exec:
....
kind: Pod
ready: true
namespaceSelector:
name: default
```
#### Kubeconfig from local filesystem
```yaml title="remote-cluster.yaml" {10-11}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: pod-creation-test
spec:
schedule: "@every 5m"
kubernetes:
- name: pod creation on aws cluster
namespace: default
kubeconfig:
value: /root/.kube/aws-kubeconfig
kind: Pod
ready: true
namespaceSelector:
name: default
```
136 changes: 128 additions & 8 deletions mission-control/docs/topology/lookups/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Kubernetes

The Kubernetes component lookup fetches kubernetes resources to be used as components.

```yaml title="kube-check.yml"
```yaml title="kube-configmap-components.yml"
---
apiVersion: canaries.flanksource.com/v1
kind: Topology
Expand All @@ -15,7 +15,7 @@ metadata:
spec:
type: Config
icon: kubernetes
schedule: '@every 30s'
schedule: '@every 5m'
components:
- name: configs
icon: server
Expand All @@ -24,12 +24,13 @@ spec:
lookup:
kubernetes:
- kind: ConfigMap
display:
expr: |
dyn(results).map(c, {
'name': c.name,
'type': 'ConfigMap',
}).toJSON()
display:
expr: |
dyn(results).map(c, {
'name': c.Object.metadata.name,
'type': 'ConfigMap',
}).toJSON()
// highlight-end
```

Expand All @@ -55,3 +56,122 @@ spec:
## Results

The `results` variable in the template is itself a list of all the kubernetes resources.

## Remote clusters

A single canary-checker instance can connect to any number of remote clusters via custom kubeconfig.
Either the kubeconfig itself or the path to the kubeconfig can be provided.

### From kubernetes secret

```yaml title="remote-cluster.yaml"
---
apiVersion: canaries.flanksource.com/v1
kind: Topology
metadata:
name: kubernetes-configs
spec:
type: Config
icon: kubernetes
schedule: '@every 5m'
components:
- name: configs
icon: server
type: ConfigMap
lookup:
kubernetes:
- kind: ConfigMap
display:
expr: |
dyn(results).map(c, {
'name': c.Object.metadata.name,
'type': 'ConfigMap',
}).toJSON()
// highlight-start
kubeconfig:
valueFrom:
secretKeyRef:
name: aws-kubeconfig
key: kubeconfig
// highlight-end
```

### Kubeconfig inline

```yaml title="remote-cluster.yaml"
apiVersion: canaries.flanksource.com/v1
kind: Topology
metadata:
name: kubernetes-configs
spec:
type: Config
icon: kubernetes
schedule: '@every 5m'
components:
- name: configs
icon: server
type: ConfigMap
lookup:
kubernetes:
- kind: ConfigMap
display:
expr: |
dyn(results).map(c, {
'name': c.Object.metadata.name,
'type': 'ConfigMap',
}).toJSON()
// highlight-start
kubeconfig:
value: |
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: xxxxx
server: https://xxxxx.sk1.eu-west-1.eks.amazonaws.com
name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
contexts:
- context:
cluster: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
namespace: mission-control
user: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
current-context: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
kind: Config
preferences: {}
users:
- name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
user:
exec:
....
// highlight-end
```

### From local filesystem

```yaml title="remote-cluster.yaml"
apiVersion: canaries.flanksource.com/v1
kind: Topology
metadata:
name: kubernetes-configs
spec:
type: Config
icon: kubernetes
schedule: '@every 5m'
components:
- name: configs
icon: server
type: ConfigMap
lookup:
kubernetes:
- kind: ConfigMap
display:
expr: |
dyn(results).map(c, {
'name': c.name,
'type': 'ConfigMap',
}).toJSON()
// highlight-start
kubeconfig:
value: /root/.kube/aws-kubeconfig
// highlight-end
```
1 change: 1 addition & 0 deletions styles/ignore/words-with-suggestions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ keypairs
knowledgebase
knowledgebases
Kratos
kubeconfig
kubectl
Kuberhealthy
kubernetes
Expand Down

0 comments on commit 9ea55f8

Please sign in to comment.