Skip to content

Commit

Permalink
chore: kubernetes resource checker from fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Oct 9, 2024
1 parent b16f5ea commit fe05609
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 309 deletions.
107 changes: 3 additions & 104 deletions canary-checker/docs/reference/1-kubernetes-resource.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,118 +123,17 @@ 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
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-resource-check-kubeconfig-from-secrets.yaml {12-16}
```

#### 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
```yaml title="remote-cluster.yaml" yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-resource-check-inline-kubeconfig.yaml {12-33}
```

#### 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
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-resource-check-kubeconfig-from-file.yaml {12-13}
```

### Templating
Expand Down
77 changes: 4 additions & 73 deletions canary-checker/docs/reference/1-kubernetes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,87 +76,18 @@ dyn(results).all(x, k8s.isReady(x))

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
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-check-kubeconfig-from-secrets.yaml {12-16}
```

#### 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
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-check-inline-kubeconfig.yaml {11-32}
```

#### 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
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-check-kubeconfig-from-file.yaml {11-12}
```
136 changes: 8 additions & 128 deletions mission-control/docs/topology/lookups/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,8 @@ title: Kubernetes

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

```yaml title="kube-configmap-components.yml"
---
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
// highlight-start
lookup:
kubernetes:
- kind: ConfigMap
display:
expr: |
dyn(results).map(c, {
'name': c.Object.metadata.name,
'type': 'ConfigMap',
}).toJSON()
// highlight-end
```yaml title="kube-configmap-components.yaml" file=../../../modules/canary-checker/fixtures/topology/kubernetes-lookup.yaml {14-22}

```

| Field | Description | Scheme | Required |
Expand Down Expand Up @@ -64,114 +40,18 @@ 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
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/topology/kubernetes-lookup-kubeconfig-from-secrets.yaml {23-27}

```

### 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
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/topology/kubernetes-lookup-inline-configmap.yaml {22-48}

```

### 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
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/topology/kubernetes-lookup-kubeconfig-from-file.yaml {22-23}

```
2 changes: 1 addition & 1 deletion modules/duty
2 changes: 1 addition & 1 deletion modules/mission-control

0 comments on commit fe05609

Please sign in to comment.