Add generic kubernetes resource analyzer (#780)

* First draft of a generic cluster-resource analyzer

* Add more resource mappings

* Support some cluster-scoped resources

the structure of this could probably be a bit tidyer, but this now
allows us to target non-namespaced resources simply by not specifying
the namespace in the analyzer.

* General tidy up

* pull resource selection into it's own function

* remove pointless pointer to string

* Export findResource function

This lets other analyzers use it.

* Add tests for cluster resources analyzer

* Update schemas

* Address some of @banjoh's comments

* rework resource selection

thanks @banjoh

* Replace FindFiles with GetFile

Since we already know where we're looking for files,
it doesn't make sense to have to loop over a single item slice.

* Use assert instead of require

* format

* Change default behaviour for no namespace

Now not providing a namespace causes us to default to "default", with an
explicit bool to toggle cluster-scoped resource checking.

This should feel somewhat more intuitive when writing analyzers that use
this function

* Generate schemas

* Value → expectedValue
This commit is contained in:
danj-replicated
2022-12-19 11:31:43 -04:00
committed by GitHub
parent f2be6f5829
commit e48fa36eaf
21 changed files with 19940 additions and 0 deletions
@@ -142,6 +142,71 @@ spec:
required:
- outcomes
type: object
clusterResource:
properties:
annotations:
additionalProperties:
type: string
type: object
checkName:
type: string
clusterScoped:
type: boolean
collectorName:
type: string
exclude:
type: BoolString
expectedValue:
type: string
kind:
type: string
name:
type: string
namespace:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
strict:
type: BoolString
yamlPath:
type: string
required:
- clusterScoped
- kind
- name
- outcomes
- yamlPath
type: object
clusterVersion:
properties:
annotations:
@@ -142,6 +142,71 @@ spec:
required:
- outcomes
type: object
clusterResource:
properties:
annotations:
additionalProperties:
type: string
type: object
checkName:
type: string
clusterScoped:
type: boolean
collectorName:
type: string
exclude:
type: BoolString
expectedValue:
type: string
kind:
type: string
name:
type: string
namespace:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
strict:
type: BoolString
yamlPath:
type: string
required:
- clusterScoped
- kind
- name
- outcomes
- yamlPath
type: object
clusterVersion:
properties:
annotations:
@@ -173,6 +173,71 @@ spec:
required:
- outcomes
type: object
clusterResource:
properties:
annotations:
additionalProperties:
type: string
type: object
checkName:
type: string
clusterScoped:
type: boolean
collectorName:
type: string
exclude:
type: BoolString
expectedValue:
type: string
kind:
type: string
name:
type: string
namespace:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
strict:
type: BoolString
yamlPath:
type: string
required:
- clusterScoped
- kind
- name
- outcomes
- yamlPath
type: object
clusterVersion:
properties:
annotations:
+14
View File
@@ -210,6 +210,20 @@ func Analyze(analyzer *troubleshootv1beta2.Analyze, getFile getCollectedFileCont
}
return results, nil
}
if analyzer.ClusterResource != nil {
isExcluded, err := isExcluded(analyzer.ClusterResource.Exclude)
if err != nil {
return nil, err
}
if isExcluded {
return nil, nil
}
result, err := analyzeResource(analyzer.ClusterResource, getFile)
if err != nil {
return nil, err
}
return []*AnalyzeResult{result}, nil
}
if analyzer.StatefulsetStatus != nil {
isExcluded, err := isExcluded(analyzer.StatefulsetStatus.Exclude)
if err != nil {
@@ -0,0 +1,459 @@
{
"kind": "DeploymentList",
"apiVersion": "apps/v1",
"metadata": {
"resourceVersion": "27195651"
},
"items": [
{
"metadata": {
"name": "kotsadm-api",
"namespace": "default",
"selfLink": "/apis/apps/v1/namespaces/default/deployments/kotsadm-api",
"uid": "56526035-cd29-4d08-8375-291503b1a006",
"resourceVersion": "1583068",
"generation": 1,
"creationTimestamp": "2019-11-07T00:34:32Z",
"labels": {
"app.kubernetes.io/managed-by": "skaffold-v0.41.0"
},
"annotations": {
"deployment.kubernetes.io/revision": "1",
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"metadata\":{\"annotations\":{},\"labels\":{\"app.kubernetes.io/managed-by\":\"skaffold-v0.41.0\",\"skaffold.dev/builder\":\"local\",\"skaffold.dev/cleanup\":\"true\",\"skaffold.dev/deployer\":\"kustomize\",\"skaffold.dev/docker-api-version\":\"1.40\",\"skaffold.dev/run-id\":\"98f0a02b-9739-4d94-ba11-3e4d273c743e\",\"skaffold.dev/tag-policy\":\"git-commit\",\"skaffold.dev/tail\":\"true\"},\"name\":\"kotsadm-api\",\"namespace\":\"default\"},\"spec\":{\"selector\":{\"matchLabels\":{\"app\":\"kotsadm-api\"}},\"template\":{\"metadata\":{\"labels\":{\"app\":\"kotsadm-api\",\"app.kubernetes.io/managed-by\":\"skaffold-v0.41.0\",\"skaffold.dev/builder\":\"local\",\"skaffold.dev/cleanup\":\"true\",\"skaffold.dev/deployer\":\"kustomize\",\"skaffold.dev/docker-api-version\":\"1.40\",\"skaffold.dev/run-id\":\"98f0a02b-9739-4d94-ba11-3e4d273c743e\",\"skaffold.dev/tag-policy\":\"git-commit\",\"skaffold.dev/tail\":\"true\"}},\"spec\":{\"affinity\":{\"podAffinity\":{\"preferredDuringSchedulingIgnoredDuringExecution\":[{\"podAffinityTerm\":{\"labelSelector\":{\"matchExpressions\":[{\"key\":\"app\",\"operator\":\"In\",\"values\":[\"ship-www\"]}]},\"topologyKey\":\"kubernetes.io/hostname\"},\"weight\":1}]},\"podAntiAffinity\":{\"preferredDuringSchedulingIgnoredDuringExecution\":[{\"podAffinityTerm\":{\"labelSelector\":{\"matchExpressions\":[{\"key\":\"app\",\"operator\":\"In\",\"values\":[\"kotsadm-api\"]}]},\"topologyKey\":\"kubernetes.io/hostname\"},\"weight\":2}]}},\"containers\":[{\"env\":[{\"name\":\"DEV_NAMESPACE\",\"value\":\"test\"},{\"name\":\"LOG_LEVEL\",\"value\":\"debug\"},{\"name\":\"SESSION_KEY\",\"valueFrom\":{\"secretKeyRef\":{\"key\":\"key\",\"name\":\"session\"}}},{\"name\":\"POSTGRES_URI\",\"valueFrom\":{\"secretKeyRef\":{\"key\":\"uri\",\"name\":\"ship-postgres\"}}},{\"name\":\"API_ENCRYPTION_KEY\",\"value\":\"IvWItkB8+ezMisPjSMBknT1PdKjBx7Xc/txZqOP8Y2Oe7+Jy\"},{\"name\":\"INIT_SERVER_URI\",\"value\":\"http://init-server:3000\"},{\"name\":\"WATCH_SERVER_URI\",\"value\":\"http://watch-server:3000\"},{\"name\":\"PINO_LOG_PRETTY\",\"value\":\"1\"},{\"name\":\"S3_BUCKET_NAME\",\"value\":\"shipbucket\"},{\"name\":\"AIRGAP_BUNDLE_S3_BUCKET\",\"value\":\"airgap\"},{\"name\":\"S3_ENDPOINT\",\"value\":\"http://kotsadm-s3.default.svc.cluster.local:4569/\"},{\"name\":\"S3_ACCESS_KEY_ID\",\"value\":\"***HIDDEN***\"},{\"name\":\"S3_SECRET_ACCESS_KEY\",\"value\":\"***HIDDEN***\"},{\"name\":\"S3_BUCKET_ENDPOINT\",\"value\":\"true\"},{\"name\":\"GITHUB_CLIENT_ID\",\"valueFrom\":{\"secretKeyRef\":{\"key\":\"client-id\",\"name\":\"github-app\"}}},{\"name\":\"GITHUB_CLIENT_SECRET\",\"valueFrom\":{\"secretKeyRef\":{\"key\":\"client-secret\",\"name\":\"github-app\"}}},{\"name\":\"GITHUB_INTEGRATION_ID\",\"valueFrom\":{\"secretKeyRef\":{\"key\":\"integration-id\",\"name\":\"github-app\"}}},{\"name\":\"GITHUB_PRIVATE_KEY_FILE\",\"value\":\"/keys/github/private-key.pem\"},{\"name\":\"SHIP_API_ENDPOINT\",\"value\":\"http://kotsadm-api.default.svc.cluster.local:3000\"},{\"name\":\"SHIP_API_ADVERTISE_ENDPOINT\",\"value\":\"http://localhost:30065\"},{\"name\":\"GRAPHQL_PREM_ENDPOINT\",\"value\":\"http://graphql-api-prem:3000/graphql\"},{\"name\":\"AUTO_CREATE_CLUSTER\",\"value\":\"1\"},{\"name\":\"AUTO_CREATE_CLUSTER_NAME\",\"value\":\"microk8s\"},{\"name\":\"AUTO_CREATE_CLUSTER_TOKEN\",\"value\":\"***HIDDEN***\"},{\"name\":\"ENABLE_SHIP\",\"value\":\"1\"},{\"name\":\"ENABLE_KOTS\",\"value\":\"1\"},{\"name\":\"ENABLE_KURL\",\"value\":\"1\"},{\"name\":\"POD_NAMESPACE\",\"valueFrom\":{\"fieldRef\":{\"fieldPath\":\"metadata.namespace\"}}}],\"image\":\"localhost:32000/kotsadm-api:v1.0.1-30-g8fa13e34-dirty@sha256:4a0ca1a2eae46472bd2d454f9e763a458ddd172689e179b17054262507bb4fc8\",\"imagePullPolicy\":\"IfNotPresent\",\"name\":\"kotsadm-api\",\"ports\":[{\"containerPort\":3000,\"name\":\"http\"},{\"containerPort\":9229,\"name\":\"debug\"}],\"readinessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":3000},\"initialDelaySeconds\":2,\"periodSeconds\":2},\"volumeMounts\":[{\"mountPath\":\"/keys/github\",\"name\":\"github-app-private-key\",\"readOnly\":true}]}],\"restartPolicy\":\"Always\",\"securityContext\":{\"runAsUser\":0},\"serviceAccount\":\"kotsadm-api\",\"volumes\":[{\"name\":\"github-app-private-key\",\"secret\":{\"secretName\":\"github-app-private-key\"}}]}}}}\n"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"app": "kotsadm-api"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "kotsadm-api"
}
},
"spec": {
"containers": [
{
"name": "kotsadm-api",
"image": "localhost:32000/kotsadm-api:v1.0.1-30-g8fa13e34-dirty@sha256:4a0ca1a2eae46472bd2d454f9e763a458ddd172689e179b17054262507bb4fc8",
"ports": [
{
"name": "http",
"containerPort": 3000,
"protocol": "TCP"
}
],
"env": [
{
"name": "DEV_NAMESPACE",
"value": "test"
},
{
"name": "POD_NAMESPACE",
"valueFrom": {
"fieldRef": {
"apiVersion": "v1",
"fieldPath": "metadata.namespace"
}
}
}
],
"resources": {},
"readinessProbe": {
"httpGet": {
"path": "/healthz",
"port": 3000,
"scheme": "HTTP"
},
"initialDelaySeconds": 2,
"timeoutSeconds": 1,
"periodSeconds": 2,
"successThreshold": 1,
"failureThreshold": 3
},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent"
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"serviceAccountName": "kotsadm-api",
"serviceAccount": "kotsadm-api",
"schedulerName": "default-scheduler"
}
},
"strategy": {
"type": "RollingUpdate",
"rollingUpdate": {
"maxUnavailable": "25%",
"maxSurge": "25%"
}
},
"revisionHistoryLimit": 10,
"progressDeadlineSeconds": 600
},
"status": {
"observedGeneration": 1,
"replicas": 1,
"updatedReplicas": 1,
"readyReplicas": 1,
"availableReplicas": 1,
"conditions": [
{
"type": "Available",
"status": "True",
"lastUpdateTime": "2019-11-07T00:35:23Z",
"lastTransitionTime": "2019-11-07T00:35:23Z",
"reason": "MinimumReplicasAvailable",
"message": "Deployment has minimum availability."
},
{
"type": "Progressing",
"status": "True",
"lastUpdateTime": "2019-11-07T00:35:23Z",
"lastTransitionTime": "2019-11-07T00:34:32Z",
"reason": "NewReplicaSetAvailable",
"message": "ReplicaSet \"kotsadm-api-6f4b994bd5\" has successfully progressed."
}
]
}
},
{
"metadata": {
"name": "kotsadm-operator",
"namespace": "default",
"selfLink": "/apis/apps/v1/namespaces/default/deployments/kotsadm-operator",
"uid": "cfae9877-eef4-44c9-acac-0bf0d1aa547e",
"resourceVersion": "1583379",
"generation": 2,
"creationTimestamp": "2019-11-07T00:34:32Z",
"labels": {
"app.kubernetes.io/managed-by": "skaffold-v0.41.0"
},
"annotations": {
"deployment.kubernetes.io/revision": "2",
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"metadata\":{\"annotations\":{},\"labels\":{\"app.kubernetes.io/managed-by\":\"skaffold-v0.41.0\",\"skaffold.dev/builder\":\"local\",\"skaffold.dev/cleanup\":\"true\",\"skaffold.dev/deployer\":\"kustomize\",\"skaffold.dev/docker-api-version\":\"1.40\",\"skaffold.dev/run-id\":\"98f0a02b-9739-4d94-ba11-3e4d273c743e\",\"skaffold.dev/tag-policy\":\"git-commit\",\"skaffold.dev/tail\":\"true\"},\"name\":\"kotsadm-operator\",\"namespace\":\"default\"},\"spec\":{\"selector\":{\"matchLabels\":{\"app\":\"kotsadm-operator\"}},\"template\":{\"metadata\":{\"labels\":{\"app\":\"kotsadm-operator\",\"app.kubernetes.io/managed-by\":\"skaffold-v0.41.0\",\"skaffold.dev/builder\":\"local\",\"skaffold.dev/cleanup\":\"true\",\"skaffold.dev/deployer\":\"kustomize\",\"skaffold.dev/docker-api-version\":\"1.40\",\"skaffold.dev/run-id\":\"98f0a02b-9739-4d94-ba11-3e4d273c743e\",\"skaffold.dev/tag-policy\":\"git-commit\",\"skaffold.dev/tail\":\"true\"}},\"spec\":{\"containers\":[{\"env\":[{\"name\":\"KOTSADM_API_ENDPOINT\",\"value\":\"http://kotsadm-api:3000\"},{\"name\":\"KOTSADM_TOKEN\",\"value\":\"***HIDDEN***\"},{\"name\":\"KOTSADM_TARGET_NAMESPACE\",\"value\":\"test\"}],\"image\":\"localhost:32000/kotsadm-operator:v1.0.1-30-g8fa13e34-dirty@sha256:177c15b6399717048e9355bc8fd8b8ed213be90615c7c6ee7b7fdcee50aca6c5\",\"imagePullPolicy\":\"Always\",\"name\":\"kotsadm-operator\",\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"1000Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"500Mi\"}}}],\"restartPolicy\":\"Always\"}}}}\n"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"app": "kotsadm-operator"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "kotsadm-operator"
}
},
"spec": {
"containers": [
{
"name": "kotsadm-operator",
"image": "localhost:32000/kotsadm-operator:v1.0.1-30-g8fa13e34-dirty@sha256:177c15b6399717048e9355bc8fd8b8ed213be90615c7c6ee7b7fdcee50aca6c5",
"env": [
{
"name": "KOTSADM_API_ENDPOINT",
"value": "http://kotsadm-api:3000"
},
{
"name": "KOTSADM_TOKEN",
"value": "***HIDDEN***"
},
{
"name": "KOTSADM_TARGET_NAMESPACE",
"value": "test"
}
],
"resources": {
"limits": {
"cpu": "200m",
"memory": "1000Mi"
},
"requests": {
"cpu": "100m",
"memory": "500Mi"
}
},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "Always"
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"schedulerName": "default-scheduler"
}
},
"strategy": {
"type": "RollingUpdate",
"rollingUpdate": {
"maxUnavailable": "25%",
"maxSurge": "25%"
}
},
"revisionHistoryLimit": 10,
"progressDeadlineSeconds": 600
},
"status": {
"observedGeneration": 2,
"replicas": 1,
"updatedReplicas": 1,
"readyReplicas": 1,
"availableReplicas": 1,
"conditions": [
{
"type": "Available",
"status": "True",
"lastUpdateTime": "2019-11-07T00:34:37Z",
"lastTransitionTime": "2019-11-07T00:34:37Z",
"reason": "MinimumReplicasAvailable",
"message": "Deployment has minimum availability."
},
{
"type": "Progressing",
"status": "True",
"lastUpdateTime": "2019-11-07T00:36:34Z",
"lastTransitionTime": "2019-11-07T00:34:32Z",
"reason": "NewReplicaSetAvailable",
"message": "ReplicaSet \"kotsadm-operator-5b5c977699\" has successfully progressed."
}
]
}
},
{
"metadata": {
"name": "kotsadm-postgres-watch",
"namespace": "default",
"selfLink": "/apis/apps/v1/namespaces/default/deployments/kotsadm-postgres-watch",
"uid": "ec195b07-4fd2-4bbe-8b01-4cbdfbe0e79d",
"resourceVersion": "1582762",
"generation": 1,
"creationTimestamp": "2019-11-07T00:34:39Z",
"annotations": {
"deployment.kubernetes.io/revision": "1"
},
"ownerReferences": [
{
"apiVersion": "databases.schemahero.io/v1alpha2",
"kind": "Database",
"name": "kotsadm-postgres",
"uid": "e6d51ce6-c4c1-428f-9e8e-56f1a3a43588",
"controller": true,
"blockOwnerDeletion": true
}
]
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"deployment": "kotsadm-postgreswatch"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"deployment": "kotsadm-postgreswatch"
}
},
"spec": {
"containers": [
{
"name": "schemahero",
"image": "schemahero/schemahero:alpha",
"args": [
"watch",
"--driver",
"postgres",
"--uri",
"postgres://shipcloud:password@postgres.default.svc.cluster.local:5432/shipcloud?sslmode=disable",
"--namespace",
"default",
"--instance",
"kotsadm-postgres"
],
"resources": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "Always"
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"serviceAccountName": "kotsadm-postgres",
"serviceAccount": "kotsadm-postgres",
"securityContext": {},
"schedulerName": "default-scheduler"
}
},
"strategy": {
"type": "RollingUpdate",
"rollingUpdate": {
"maxUnavailable": "25%",
"maxSurge": "25%"
}
},
"revisionHistoryLimit": 10,
"progressDeadlineSeconds": 600
},
"status": {
"observedGeneration": 1,
"replicas": 1,
"updatedReplicas": 1,
"readyReplicas": 1,
"availableReplicas": 1,
"conditions": [
{
"type": "Available",
"status": "True",
"lastUpdateTime": "2019-11-07T00:35:00Z",
"lastTransitionTime": "2019-11-07T00:35:00Z",
"reason": "MinimumReplicasAvailable",
"message": "Deployment has minimum availability."
},
{
"type": "Progressing",
"status": "True",
"lastUpdateTime": "2019-11-07T00:35:00Z",
"lastTransitionTime": "2019-11-07T00:34:39Z",
"reason": "NewReplicaSetAvailable",
"message": "ReplicaSet \"kotsadm-postgres-watch-5cf76f4c45\" has successfully progressed."
}
]
}
},
{
"metadata": {
"name": "kotsadm-web",
"namespace": "default",
"selfLink": "/apis/apps/v1/namespaces/default/deployments/kotsadm-web",
"uid": "4e657f8a-5edb-498b-9402-1f93f51f5dda",
"resourceVersion": "1582354",
"generation": 1,
"creationTimestamp": "2019-11-07T00:34:32Z",
"labels": {
"app.kubernetes.io/managed-by": "skaffold-v0.41.0",
"skaffold.dev/builder": "local",
"skaffold.dev/cleanup": "true",
"skaffold.dev/deployer": "kustomize",
"skaffold.dev/docker-api-version": "1.40",
"skaffold.dev/run-id": "98f0a02b-9739-4d94-ba11-3e4d273c743e",
"skaffold.dev/tag-policy": "git-commit",
"skaffold.dev/tail": "true"
},
"annotations": {
"deployment.kubernetes.io/revision": "1",
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"metadata\":{\"annotations\":{},\"labels\":{\"app.kubernetes.io/managed-by\":\"skaffold-v0.41.0\",\"skaffold.dev/builder\":\"local\",\"skaffold.dev/cleanup\":\"true\",\"skaffold.dev/deployer\":\"kustomize\",\"skaffold.dev/docker-api-version\":\"1.40\",\"skaffold.dev/run-id\":\"98f0a02b-9739-4d94-ba11-3e4d273c743e\",\"skaffold.dev/tag-policy\":\"git-commit\",\"skaffold.dev/tail\":\"true\"},\"name\":\"kotsadm-web\",\"namespace\":\"default\"},\"spec\":{\"selector\":{\"matchLabels\":{\"app\":\"kotsadm-web\"}},\"template\":{\"metadata\":{\"labels\":{\"app\":\"kotsadm-web\",\"app.kubernetes.io/managed-by\":\"skaffold-v0.41.0\",\"skaffold.dev/builder\":\"local\",\"skaffold.dev/cleanup\":\"true\",\"skaffold.dev/deployer\":\"kustomize\",\"skaffold.dev/docker-api-version\":\"1.40\",\"skaffold.dev/run-id\":\"98f0a02b-9739-4d94-ba11-3e4d273c743e\",\"skaffold.dev/tag-policy\":\"git-commit\",\"skaffold.dev/tail\":\"true\"}},\"spec\":{\"containers\":[{\"env\":[{\"name\":\"GITHUB_CLIENT_ID\",\"valueFrom\":{\"secretKeyRef\":{\"key\":\"client-id\",\"name\":\"github-app\"}}},{\"name\":\"GITHUB_INSTALL_URL\",\"valueFrom\":{\"secretKeyRef\":{\"key\":\"install-url\",\"name\":\"github-app\"}}},{\"name\":\"SHIP_CLUSTER_API_SERVER\",\"value\":\"http://localhost:30065\"},{\"name\":\"SHIP_CLUSTER_WEB_URI\",\"value\":\"http://localhost:8000\"}],\"image\":\"localhost:32000/kotsadm-web:v1.0.1-30-g8fa13e34@sha256:5b5b5b640b6e09d8b3185d4ae15ac4dc558d4e2ea034ac3e567d8cce04eadb9c\",\"imagePullPolicy\":\"IfNotPresent\",\"name\":\"kotsadm-web\",\"ports\":[{\"containerPort\":8000,\"name\":\"http\"}]}]}}}}\n"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"app": "kotsadm-web"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "kotsadm-web",
"app.kubernetes.io/managed-by": "skaffold-v0.41.0",
"skaffold.dev/builder": "local",
"skaffold.dev/cleanup": "true",
"skaffold.dev/deployer": "kustomize",
"skaffold.dev/docker-api-version": "1.40",
"skaffold.dev/run-id": "98f0a02b-9739-4d94-ba11-3e4d273c743e",
"skaffold.dev/tag-policy": "git-commit",
"skaffold.dev/tail": "true"
}
},
"spec": {
"containers": [
{
"name": "kotsadm-web",
"image": "localhost:32000/kotsadm-web:v1.0.1-30-g8fa13e34@sha256:5b5b5b640b6e09d8b3185d4ae15ac4dc558d4e2ea034ac3e567d8cce04eadb9c",
"ports": [
{
"name": "http",
"containerPort": 8000,
"protocol": "TCP"
}
],
"env": [
{
"name": "GITHUB_CLIENT_ID",
"valueFrom": {
"secretKeyRef": {
"name": "github-app",
"key": "client-id"
}
}
}
],
"resources": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent"
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"schedulerName": "default-scheduler"
}
},
"strategy": {
"type": "RollingUpdate",
"rollingUpdate": {
"maxUnavailable": "25%",
"maxSurge": "25%"
}
},
"revisionHistoryLimit": 10,
"progressDeadlineSeconds": 600
},
"status": {
"observedGeneration": 1,
"replicas": 2,
"updatedReplicas": 1,
"readyReplicas": 1,
"availableReplicas": 1,
"conditions": [
{
"type": "Available",
"status": "True",
"lastUpdateTime": "2019-11-07T00:34:39Z",
"lastTransitionTime": "2019-11-07T00:34:39Z",
"reason": "MinimumReplicasAvailable",
"message": "Deployment has minimum availability."
},
{
"type": "Progressing",
"status": "True",
"lastUpdateTime": "2019-11-07T00:34:39Z",
"lastTransitionTime": "2019-11-07T00:34:32Z",
"reason": "NewReplicaSetAvailable",
"message": "ReplicaSet \"kotsadm-web-79bfb95c48\" has successfully progressed."
}
]
}
}
]
}
@@ -0,0 +1,667 @@
{
"kind": "DeploymentList",
"apiVersion": "apps/v1",
"metadata": {
"resourceVersion": "27195652"
},
"items": [
{
"metadata": {
"name": "coredns",
"namespace": "kube-system",
"selfLink": "/apis/apps/v1/namespaces/kube-system/deployments/coredns",
"uid": "4e008c0d-39fd-4c54-acb7-45ad67c91ef4",
"resourceVersion": "734",
"generation": 1,
"creationTimestamp": "2021-12-17T18:38:57Z",
"labels": {
"k8s-app": "kube-dns"
},
"annotations": {
"deployment.kubernetes.io/revision": "1"
},
"managedFields": [
{
"manager": "kubeadm",
"operation": "Update",
"apiVersion": "apps/v1",
"time": "2021-12-17T18:38:57Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:labels": {
".": {},
"f:k8s-app": {}
}
},
"f:spec": {
"f:progressDeadlineSeconds": {},
"f:replicas": {},
"f:revisionHistoryLimit": {},
"f:selector": {
"f:matchLabels": {
".": {},
"f:k8s-app": {}
}
},
"f:strategy": {
"f:rollingUpdate": {
".": {},
"f:maxSurge": {},
"f:maxUnavailable": {}
},
"f:type": {}
},
"f:template": {
"f:metadata": {
"f:labels": {
".": {},
"f:k8s-app": {}
}
},
"f:spec": {
"f:containers": {
"k:{\"name\":\"coredns\"}": {
".": {},
"f:args": {},
"f:image": {},
"f:imagePullPolicy": {},
"f:livenessProbe": {
".": {},
"f:failureThreshold": {},
"f:httpGet": {
".": {},
"f:path": {},
"f:port": {},
"f:scheme": {}
},
"f:initialDelaySeconds": {},
"f:periodSeconds": {},
"f:successThreshold": {},
"f:timeoutSeconds": {}
},
"f:name": {},
"f:ports": {
".": {},
"k:{\"containerPort\":53,\"protocol\":\"TCP\"}": {
".": {},
"f:containerPort": {},
"f:name": {},
"f:protocol": {}
},
"k:{\"containerPort\":53,\"protocol\":\"UDP\"}": {
".": {},
"f:containerPort": {},
"f:name": {},
"f:protocol": {}
},
"k:{\"containerPort\":9153,\"protocol\":\"TCP\"}": {
".": {},
"f:containerPort": {},
"f:name": {},
"f:protocol": {}
}
},
"f:readinessProbe": {
".": {},
"f:failureThreshold": {},
"f:httpGet": {
".": {},
"f:path": {},
"f:port": {},
"f:scheme": {}
},
"f:periodSeconds": {},
"f:successThreshold": {},
"f:timeoutSeconds": {}
},
"f:resources": {
".": {},
"f:limits": {
".": {},
"f:memory": {}
},
"f:requests": {
".": {},
"f:cpu": {},
"f:memory": {}
}
},
"f:securityContext": {
".": {},
"f:allowPrivilegeEscalation": {},
"f:capabilities": {
".": {},
"f:add": {},
"f:drop": {}
},
"f:readOnlyRootFilesystem": {}
},
"f:terminationMessagePath": {},
"f:terminationMessagePolicy": {},
"f:volumeMounts": {
".": {},
"k:{\"mountPath\":\"/etc/coredns\"}": {
".": {},
"f:mountPath": {},
"f:name": {},
"f:readOnly": {}
}
}
}
},
"f:dnsPolicy": {},
"f:nodeSelector": {
".": {},
"f:kubernetes.io/os": {}
},
"f:priorityClassName": {},
"f:restartPolicy": {},
"f:schedulerName": {},
"f:securityContext": {},
"f:serviceAccount": {},
"f:serviceAccountName": {},
"f:terminationGracePeriodSeconds": {},
"f:tolerations": {},
"f:volumes": {
".": {},
"k:{\"name\":\"config-volume\"}": {
".": {},
"f:configMap": {
".": {},
"f:defaultMode": {},
"f:items": {},
"f:name": {}
},
"f:name": {}
}
}
}
}
}
}
},
{
"manager": "kube-controller-manager",
"operation": "Update",
"apiVersion": "apps/v1",
"time": "2021-12-17T18:39:42Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:annotations": {
".": {},
"f:deployment.kubernetes.io/revision": {}
}
},
"f:status": {
"f:availableReplicas": {},
"f:conditions": {
".": {},
"k:{\"type\":\"Available\"}": {
".": {},
"f:lastTransitionTime": {},
"f:lastUpdateTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"Progressing\"}": {
".": {},
"f:lastTransitionTime": {},
"f:lastUpdateTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
}
},
"f:observedGeneration": {},
"f:readyReplicas": {},
"f:replicas": {},
"f:updatedReplicas": {}
}
}
}
]
},
"spec": {
"replicas": 2,
"selector": {
"matchLabels": {
"k8s-app": "kube-dns"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"k8s-app": "kube-dns"
}
},
"spec": {
"volumes": [
{
"name": "config-volume",
"configMap": {
"name": "coredns",
"items": [
{
"key": "Corefile",
"path": "Corefile"
}
],
"defaultMode": 420
}
}
],
"containers": [
{
"name": "coredns",
"image": "k8s.gcr.io/coredns:1.7.0",
"args": [
"-conf",
"/etc/coredns/Corefile"
],
"ports": [
{
"name": "dns",
"containerPort": 53,
"protocol": "UDP"
},
{
"name": "dns-tcp",
"containerPort": 53,
"protocol": "TCP"
},
{
"name": "metrics",
"containerPort": 9153,
"protocol": "TCP"
}
],
"resources": {
"limits": {
"memory": "170Mi"
},
"requests": {
"cpu": "100m",
"memory": "70Mi"
}
},
"volumeMounts": [
{
"name": "config-volume",
"readOnly": true,
"mountPath": "/etc/coredns"
}
],
"livenessProbe": {
"httpGet": {
"path": "/health",
"port": 8080,
"scheme": "HTTP"
},
"initialDelaySeconds": 60,
"timeoutSeconds": 5,
"periodSeconds": 10,
"successThreshold": 1,
"failureThreshold": 5
},
"readinessProbe": {
"httpGet": {
"path": "/ready",
"port": 8181,
"scheme": "HTTP"
},
"timeoutSeconds": 1,
"periodSeconds": 10,
"successThreshold": 1,
"failureThreshold": 3
},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent",
"securityContext": {
"capabilities": {
"add": [
"NET_BIND_SERVICE"
],
"drop": [
"all"
]
},
"readOnlyRootFilesystem": true,
"allowPrivilegeEscalation": false
}
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "Default",
"nodeSelector": {
"kubernetes.io/os": "linux"
},
"serviceAccountName": "coredns",
"serviceAccount": "coredns",
"securityContext": {},
"schedulerName": "default-scheduler",
"tolerations": [
{
"key": "CriticalAddonsOnly",
"operator": "Exists"
},
{
"key": "node-role.kubernetes.io/master",
"effect": "NoSchedule"
}
],
"priorityClassName": "system-cluster-critical"
}
},
"strategy": {
"type": "RollingUpdate",
"rollingUpdate": {
"maxUnavailable": 1,
"maxSurge": "25%"
}
},
"revisionHistoryLimit": 10,
"progressDeadlineSeconds": 600
},
"status": {
"observedGeneration": 1,
"replicas": 2,
"updatedReplicas": 2,
"readyReplicas": 2,
"availableReplicas": 2,
"conditions": [
{
"type": "Available",
"status": "True",
"lastUpdateTime": "2021-12-17T18:39:25Z",
"lastTransitionTime": "2021-12-17T18:39:25Z",
"reason": "MinimumReplicasAvailable",
"message": "Deployment has minimum availability."
},
{
"type": "Progressing",
"status": "True",
"lastUpdateTime": "2021-12-17T18:39:42Z",
"lastTransitionTime": "2021-12-17T18:39:05Z",
"reason": "NewReplicaSetAvailable",
"message": "ReplicaSet \"coredns-f9fd979d6\" has successfully progressed."
}
]
}
},
{
"metadata": {
"name": "metrics-server",
"namespace": "kube-system",
"selfLink": "/apis/apps/v1/namespaces/kube-system/deployments/metrics-server",
"uid": "2247dee8-5d1d-4e05-a6e8-a50f15db140b",
"resourceVersion": "2998",
"generation": 1,
"creationTimestamp": "2021-12-17T18:42:38Z",
"labels": {
"k8s-app": "metrics-server"
},
"annotations": {
"deployment.kubernetes.io/revision": "1",
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"metadata\":{\"annotations\":{},\"labels\":{\"k8s-app\":\"metrics-server\"},\"name\":\"metrics-server\",\"namespace\":\"kube-system\"},\"spec\":{\"selector\":{\"matchLabels\":{\"k8s-app\":\"metrics-server\"}},\"template\":{\"metadata\":{\"labels\":{\"k8s-app\":\"metrics-server\"},\"name\":\"metrics-server\"},\"spec\":{\"containers\":[{\"args\":[\"--cert-dir=/tmp\",\"--secure-port=4443\",\"--kubelet-insecure-tls\"],\"image\":\"k8s.gcr.io/metrics-server/metrics-server:v0.3.7\",\"imagePullPolicy\":\"IfNotPresent\",\"name\":\"metrics-server\",\"ports\":[{\"containerPort\":4443,\"name\":\"main-port\",\"protocol\":\"TCP\"}],\"securityContext\":{\"readOnlyRootFilesystem\":true,\"runAsNonRoot\":true,\"runAsUser\":1000},\"volumeMounts\":[{\"mountPath\":\"/tmp\",\"name\":\"tmp-dir\"}]}],\"nodeSelector\":{\"kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"metrics-server\",\"volumes\":[{\"emptyDir\":{},\"name\":\"tmp-dir\"}]}}}}\n"
},
"managedFields": [
{
"manager": "kubectl-client-side-apply",
"operation": "Update",
"apiVersion": "apps/v1",
"time": "2021-12-17T18:42:38Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:annotations": {
".": {},
"f:kubectl.kubernetes.io/last-applied-configuration": {}
},
"f:labels": {
".": {},
"f:k8s-app": {}
}
},
"f:spec": {
"f:progressDeadlineSeconds": {},
"f:replicas": {},
"f:revisionHistoryLimit": {},
"f:selector": {
"f:matchLabels": {
".": {},
"f:k8s-app": {}
}
},
"f:strategy": {
"f:rollingUpdate": {
".": {},
"f:maxSurge": {},
"f:maxUnavailable": {}
},
"f:type": {}
},
"f:template": {
"f:metadata": {
"f:labels": {
".": {},
"f:k8s-app": {}
},
"f:name": {}
},
"f:spec": {
"f:containers": {
"k:{\"name\":\"metrics-server\"}": {
".": {},
"f:args": {},
"f:image": {},
"f:imagePullPolicy": {},
"f:name": {},
"f:ports": {
".": {},
"k:{\"containerPort\":4443,\"protocol\":\"TCP\"}": {
".": {},
"f:containerPort": {},
"f:name": {},
"f:protocol": {}
}
},
"f:resources": {},
"f:securityContext": {
".": {},
"f:readOnlyRootFilesystem": {},
"f:runAsNonRoot": {},
"f:runAsUser": {}
},
"f:terminationMessagePath": {},
"f:terminationMessagePolicy": {},
"f:volumeMounts": {
".": {},
"k:{\"mountPath\":\"/tmp\"}": {
".": {},
"f:mountPath": {},
"f:name": {}
}
}
}
},
"f:dnsPolicy": {},
"f:nodeSelector": {
".": {},
"f:kubernetes.io/os": {}
},
"f:restartPolicy": {},
"f:schedulerName": {},
"f:securityContext": {},
"f:serviceAccount": {},
"f:serviceAccountName": {},
"f:terminationGracePeriodSeconds": {},
"f:volumes": {
".": {},
"k:{\"name\":\"tmp-dir\"}": {
".": {},
"f:emptyDir": {},
"f:name": {}
}
}
}
}
}
}
},
{
"manager": "kube-controller-manager",
"operation": "Update",
"apiVersion": "apps/v1",
"time": "2021-12-17T18:42:47Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:annotations": {
"f:deployment.kubernetes.io/revision": {}
}
},
"f:status": {
"f:availableReplicas": {},
"f:conditions": {
".": {},
"k:{\"type\":\"Available\"}": {
".": {},
"f:lastTransitionTime": {},
"f:lastUpdateTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"Progressing\"}": {
".": {},
"f:lastTransitionTime": {},
"f:lastUpdateTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
}
},
"f:observedGeneration": {},
"f:readyReplicas": {},
"f:replicas": {},
"f:updatedReplicas": {}
}
}
}
]
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"k8s-app": "metrics-server"
}
},
"template": {
"metadata": {
"name": "metrics-server",
"creationTimestamp": null,
"labels": {
"k8s-app": "metrics-server"
}
},
"spec": {
"volumes": [
{
"name": "tmp-dir",
"emptyDir": {}
}
],
"containers": [
{
"name": "metrics-server",
"image": "k8s.gcr.io/metrics-server/metrics-server:v0.3.7",
"args": [
"--cert-dir=/tmp",
"--secure-port=4443",
"--kubelet-insecure-tls"
],
"ports": [
{
"name": "main-port",
"containerPort": 4443,
"protocol": "TCP"
}
],
"resources": {},
"volumeMounts": [
{
"name": "tmp-dir",
"mountPath": "/tmp"
}
],
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent",
"securityContext": {
"runAsUser": 1000,
"runAsNonRoot": true,
"readOnlyRootFilesystem": true
}
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"nodeSelector": {
"kubernetes.io/os": "linux"
},
"serviceAccountName": "metrics-server",
"serviceAccount": "metrics-server",
"securityContext": {},
"schedulerName": "default-scheduler"
}
},
"strategy": {
"type": "RollingUpdate",
"rollingUpdate": {
"maxUnavailable": "25%",
"maxSurge": "25%"
}
},
"revisionHistoryLimit": 10,
"progressDeadlineSeconds": 600
},
"status": {
"observedGeneration": 1,
"replicas": 2,
"updatedReplicas": 1,
"readyReplicas": 1,
"availableReplicas": 1,
"conditions": [
{
"type": "Available",
"status": "True",
"lastUpdateTime": "2021-12-17T18:42:47Z",
"lastTransitionTime": "2021-12-17T18:42:47Z",
"reason": "MinimumReplicasAvailable",
"message": "Deployment has minimum availability."
},
{
"type": "Progressing",
"status": "True",
"lastUpdateTime": "2021-12-17T18:42:47Z",
"lastTransitionTime": "2021-12-17T18:42:38Z",
"reason": "NewReplicaSetAvailable",
"message": "ReplicaSet \"metrics-server-56df6d849\" has successfully progressed."
}
]
}
}
]
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,204 @@
{
"kind": "JobList",
"apiVersion": "batch/v1",
"metadata": {
"resourceVersion": "27195661"
},
"items": [
{
"metadata": {
"name": "contour-certgen-v1.19.1",
"namespace": "projectcontour",
"selfLink": "/apis/batch/v1/namespaces/projectcontour/jobs/contour-certgen-v1.19.1",
"uid": "416a2a9d-b862-47b8-93d9-160775641fbe",
"resourceVersion": "1386",
"creationTimestamp": "2021-12-17T18:41:14Z",
"labels": {
"app": "contour-certgen",
"controller-uid": "416a2a9d-b862-47b8-93d9-160775641fbe",
"job-name": "contour-certgen-v1.19.1"
},
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"batch/v1\",\"kind\":\"Job\",\"metadata\":{\"annotations\":{},\"name\":\"contour-certgen-v1.19.1\",\"namespace\":\"projectcontour\"},\"spec\":{\"backoffLimit\":1,\"completions\":1,\"parallelism\":1,\"template\":{\"metadata\":{\"labels\":{\"app\":\"contour-certgen\"}},\"spec\":{\"containers\":[{\"command\":[\"contour\",\"certgen\",\"--kube\",\"--incluster\",\"--overwrite\",\"--secrets-format=compact\",\"--namespace=$(CONTOUR_NAMESPACE)\"],\"env\":[{\"name\":\"CONTOUR_NAMESPACE\",\"valueFrom\":{\"fieldRef\":{\"fieldPath\":\"metadata.namespace\"}}}],\"image\":\"ghcr.io/projectcontour/contour:v1.19.1\",\"imagePullPolicy\":\"IfNotPresent\",\"name\":\"contour\"}],\"restartPolicy\":\"Never\",\"securityContext\":{\"runAsGroup\":65534,\"runAsNonRoot\":true,\"runAsUser\":65534},\"serviceAccountName\":\"contour-certgen\"}},\"ttlSecondsAfterFinished\":0}}\n"
},
"managedFields": [
{
"manager": "kubectl-client-side-apply",
"operation": "Update",
"apiVersion": "batch/v1",
"time": "2021-12-17T18:41:14Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:annotations": {
".": {},
"f:kubectl.kubernetes.io/last-applied-configuration": {}
},
"f:labels": {
".": {},
"f:app": {}
}
},
"f:spec": {
"f:backoffLimit": {},
"f:completions": {},
"f:parallelism": {},
"f:template": {
"f:metadata": {
"f:labels": {
".": {},
"f:app": {}
}
},
"f:spec": {
"f:containers": {
"k:{\"name\":\"contour\"}": {
".": {},
"f:command": {},
"f:env": {
".": {},
"k:{\"name\":\"CONTOUR_NAMESPACE\"}": {
".": {},
"f:name": {},
"f:valueFrom": {
".": {},
"f:fieldRef": {
".": {},
"f:apiVersion": {},
"f:fieldPath": {}
}
}
}
},
"f:image": {},
"f:imagePullPolicy": {},
"f:name": {},
"f:resources": {},
"f:terminationMessagePath": {},
"f:terminationMessagePolicy": {}
}
},
"f:dnsPolicy": {},
"f:restartPolicy": {},
"f:schedulerName": {},
"f:securityContext": {
".": {},
"f:runAsGroup": {},
"f:runAsNonRoot": {},
"f:runAsUser": {}
},
"f:serviceAccount": {},
"f:serviceAccountName": {},
"f:terminationGracePeriodSeconds": {}
}
},
"f:ttlSecondsAfterFinished": {}
}
}
},
{
"manager": "kube-controller-manager",
"operation": "Update",
"apiVersion": "batch/v1",
"time": "2021-12-17T18:41:17Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:status": {
"f:completionTime": {},
"f:conditions": {
".": {},
"k:{\"type\":\"Complete\"}": {
".": {},
"f:lastProbeTime": {},
"f:lastTransitionTime": {},
"f:status": {},
"f:type": {}
}
},
"f:startTime": {},
"f:succeeded": {}
}
}
}
]
},
"spec": {
"parallelism": 1,
"completions": 1,
"backoffLimit": 1,
"selector": {
"matchLabels": {
"controller-uid": "416a2a9d-b862-47b8-93d9-160775641fbe"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "contour-certgen",
"controller-uid": "416a2a9d-b862-47b8-93d9-160775641fbe",
"job-name": "contour-certgen-v1.19.1"
}
},
"spec": {
"containers": [
{
"name": "contour",
"image": "ghcr.io/projectcontour/contour:v1.19.1",
"command": [
"contour",
"certgen",
"--kube",
"--incluster",
"--overwrite",
"--secrets-format=compact",
"--namespace=$(CONTOUR_NAMESPACE)"
],
"env": [
{
"name": "CONTOUR_NAMESPACE",
"valueFrom": {
"fieldRef": {
"apiVersion": "v1",
"fieldPath": "metadata.namespace"
}
}
}
],
"resources": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent"
}
],
"restartPolicy": "Never",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"serviceAccountName": "contour-certgen",
"serviceAccount": "contour-certgen",
"securityContext": {
"runAsUser": 65534,
"runAsGroup": 65534,
"runAsNonRoot": true
},
"schedulerName": "default-scheduler"
}
}
},
"status": {
"conditions": [
{
"type": "Complete",
"status": "True",
"lastProbeTime": "2021-12-17T18:41:17Z",
"lastTransitionTime": "2021-12-17T18:41:17Z"
}
],
"startTime": "2021-12-17T18:41:14Z",
"completionTime": "2021-12-17T18:41:17Z",
"succeeded": 0,
"failed": 1
}
}
]
}
@@ -0,0 +1,325 @@
{
"kind": "JobList",
"apiVersion": "batch/v1",
"metadata": {
"resourceVersion": "27195662"
},
"items": [
{
"metadata": {
"name": "pre-install-job",
"namespace": "test",
"uid": "4545c8ba-0462-45a6-96c3-793a545dfcf6",
"resourceVersion": "8303004",
"creationTimestamp": "2021-10-05T19:11:43Z",
"labels": {
"kots.io/app-slug": "test",
"kots.io/backup": "velero"
},
"annotations": {
"helm.sh/hook": "pre-install",
"helm.sh/hook-weight": "2",
"kots.io/app-slug": "test",
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"batch/v1\",\"kind\":\"Job\",\"metadata\":{\"annotations\":{\"helm.sh/hook\":\"pre-install\",\"helm.sh/hook-weight\":\"2\",\"kots.io/app-slug\":\"test\"},\"labels\":{\"kots.io/app-slug\":\"test\",\"kots.io/backup\":\"velero\"},\"name\":\"pre-install-job\",\"namespace\":\"test\"},\"spec\":{\"backoffLimit\":3,\"template\":{\"metadata\":{\"annotations\":{\"kots.io/app-slug\":\"test\"},\"labels\":{\"kots.io/app-slug\":\"test\",\"kots.io/backup\":\"velero\"},\"name\":\"security-test\"},\"spec\":{\"containers\":[{\"command\":[\"sh\",\"-c\",\"sleep 10\"],\"image\":\"alpine\",\"imagePullPolicy\":\"IfNotPresent\",\"name\":\"hook-test\"}],\"restartPolicy\":\"Never\"}}}}\n"
},
"managedFields": [
{
"manager": "kubectl-client-side-apply",
"operation": "Update",
"apiVersion": "batch/v1",
"time": "2021-10-05T19:11:43Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:annotations": {
".": {},
"f:helm.sh/hook": {},
"f:helm.sh/hook-weight": {},
"f:kots.io/app-slug": {},
"f:kubectl.kubernetes.io/last-applied-configuration": {}
},
"f:labels": {
".": {},
"f:kots.io/app-slug": {},
"f:kots.io/backup": {}
}
},
"f:spec": {
"f:backoffLimit": {},
"f:completions": {},
"f:parallelism": {},
"f:template": {
"f:metadata": {
"f:annotations": {
".": {},
"f:kots.io/app-slug": {}
},
"f:labels": {
".": {},
"f:kots.io/app-slug": {},
"f:kots.io/backup": {}
},
"f:name": {}
},
"f:spec": {
"f:containers": {
"k:{\"name\":\"hook-test\"}": {
".": {},
"f:command": {},
"f:image": {},
"f:imagePullPolicy": {},
"f:name": {},
"f:resources": {},
"f:terminationMessagePath": {},
"f:terminationMessagePolicy": {}
}
},
"f:dnsPolicy": {},
"f:restartPolicy": {},
"f:schedulerName": {},
"f:securityContext": {},
"f:terminationGracePeriodSeconds": {}
}
}
}
}
},
{
"manager": "k3s",
"operation": "Update",
"apiVersion": "batch/v1",
"time": "2021-10-05T19:11:55Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:status": {
"f:completionTime": {},
"f:conditions": {},
"f:startTime": {},
"f:succeeded": {}
}
}
}
]
},
"spec": {
"parallelism": 1,
"completions": 1,
"backoffLimit": 3,
"selector": {
"matchLabels": {
"controller-uid": "4545c8ba-0462-45a6-96c3-793a545dfcf6"
}
},
"template": {
"metadata": {
"name": "security-test",
"creationTimestamp": null,
"labels": {
"controller-uid": "4545c8ba-0462-45a6-96c3-793a545dfcf6",
"job-name": "pre-install-job",
"kots.io/app-slug": "test",
"kots.io/backup": "velero"
},
"annotations": {
"kots.io/app-slug": "test"
}
},
"spec": {
"containers": [
{
"name": "hook-test",
"image": "alpine",
"command": [
"sh",
"-c",
"sleep 10"
],
"resources": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent"
}
],
"restartPolicy": "Never",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"schedulerName": "default-scheduler"
}
}
},
"status": {
"conditions": [
{
"type": "Complete",
"status": "True",
"lastProbeTime": "2021-10-05T19:11:55Z",
"lastTransitionTime": "2021-10-05T19:11:55Z"
}
],
"startTime": "2021-10-05T19:11:43Z",
"completionTime": "2021-10-05T19:11:55Z",
"succeeded": 1
}
},
{
"metadata": {
"name": "post-install-job",
"namespace": "test",
"uid": "13844969-d21a-4514-8bed-66157f216af7",
"resourceVersion": "8303007",
"creationTimestamp": "2021-10-05T19:11:43Z",
"labels": {
"kots.io/app-slug": "test",
"kots.io/backup": "velero"
},
"annotations": {
"helm.sh/hook": "post-install",
"helm.sh/hook-weight": "2",
"kots.io/app-slug": "test",
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"batch/v1\",\"kind\":\"Job\",\"metadata\":{\"annotations\":{\"helm.sh/hook\":\"post-install\",\"helm.sh/hook-weight\":\"2\",\"kots.io/app-slug\":\"test\"},\"labels\":{\"kots.io/app-slug\":\"test\",\"kots.io/backup\":\"velero\"},\"name\":\"post-install-job\",\"namespace\":\"test\"},\"spec\":{\"backoffLimit\":3,\"template\":{\"metadata\":{\"annotations\":{\"kots.io/app-slug\":\"test\"},\"labels\":{\"kots.io/app-slug\":\"test\",\"kots.io/backup\":\"velero\"},\"name\":\"security-test\"},\"spec\":{\"containers\":[{\"command\":[\"sh\",\"-c\",\"sleep 10\"],\"image\":\"alpine\",\"imagePullPolicy\":\"IfNotPresent\",\"name\":\"hook-test\"}],\"restartPolicy\":\"Never\"}}}}\n"
},
"managedFields": [
{
"manager": "kubectl-client-side-apply",
"operation": "Update",
"apiVersion": "batch/v1",
"time": "2021-10-05T19:11:43Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:annotations": {
".": {},
"f:helm.sh/hook": {},
"f:helm.sh/hook-weight": {},
"f:kots.io/app-slug": {},
"f:kubectl.kubernetes.io/last-applied-configuration": {}
},
"f:labels": {
".": {},
"f:kots.io/app-slug": {},
"f:kots.io/backup": {}
}
},
"f:spec": {
"f:backoffLimit": {},
"f:completions": {},
"f:parallelism": {},
"f:template": {
"f:metadata": {
"f:annotations": {
".": {},
"f:kots.io/app-slug": {}
},
"f:labels": {
".": {},
"f:kots.io/app-slug": {},
"f:kots.io/backup": {}
},
"f:name": {}
},
"f:spec": {
"f:containers": {
"k:{\"name\":\"hook-test\"}": {
".": {},
"f:command": {},
"f:image": {},
"f:imagePullPolicy": {},
"f:name": {},
"f:resources": {},
"f:terminationMessagePath": {},
"f:terminationMessagePolicy": {}
}
},
"f:dnsPolicy": {},
"f:restartPolicy": {},
"f:schedulerName": {},
"f:securityContext": {},
"f:terminationGracePeriodSeconds": {}
}
}
}
}
},
{
"manager": "k3s",
"operation": "Update",
"apiVersion": "batch/v1",
"time": "2021-10-05T19:11:55Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:status": {
"f:completionTime": {},
"f:conditions": {},
"f:startTime": {},
"f:succeeded": {}
}
}
}
]
},
"spec": {
"parallelism": 1,
"completions": 1,
"backoffLimit": 3,
"selector": {
"matchLabels": {
"controller-uid": "13844969-d21a-4514-8bed-66157f216af7"
}
},
"template": {
"metadata": {
"name": "security-test",
"creationTimestamp": null,
"labels": {
"controller-uid": "13844969-d21a-4514-8bed-66157f216af7",
"job-name": "post-install-job",
"kots.io/app-slug": "test",
"kots.io/backup": "velero"
},
"annotations": {
"kots.io/app-slug": "test"
}
},
"spec": {
"containers": [
{
"name": "hook-test",
"image": "alpine",
"command": [
"sh",
"-c",
"sleep 10"
],
"resources": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent"
}
],
"restartPolicy": "Never",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"schedulerName": "default-scheduler"
}
}
},
"status": {
"conditions": [
{
"type": "Failed",
"status": "True",
"lastProbeTime": "2021-10-05T19:11:55Z",
"lastTransitionTime": "2021-10-05T19:11:55Z",
"message": "Job has reached the specified backoff limit",
"reason": "BackoffLimitExceeded"
}
],
"startTime": "2021-10-05T19:11:43Z",
"completionTime": "2021-10-05T19:11:55Z",
"failed": 1
}
}
]
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,418 @@
{
"kind": "StatefulSetList",
"apiVersion": "apps/v1",
"metadata": {
"resourceVersion": "27195654"
},
"items": [
{
"metadata": {
"name": "kotsadm-postgres",
"namespace": "default",
"selfLink": "/apis/apps/v1/namespaces/default/statefulsets/kotsadm-postgres",
"uid": "7b8a5a95-98bf-4b37-b302-7f55e5af844b",
"resourceVersion": "2185",
"generation": 1,
"creationTimestamp": "2021-12-17T18:41:34Z",
"labels": {
"kots.io/backup": "velero",
"kots.io/kotsadm": "true"
},
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"apps/v1\",\"kind\":\"StatefulSet\",\"metadata\":{\"annotations\":{},\"labels\":{\"kots.io/backup\":\"velero\",\"kots.io/kotsadm\":\"true\"},\"name\":\"kotsadm-postgres\",\"namespace\":\"default\"},\"spec\":{\"replicas\":1,\"selector\":{\"matchLabels\":{\"app\":\"kotsadm-postgres\"}},\"serviceName\":\"kotsadm-postgres\",\"template\":{\"metadata\":{\"labels\":{\"app\":\"kotsadm-postgres\",\"kots.io/backup\":\"velero\",\"kots.io/kotsadm\":\"true\"}},\"spec\":{\"containers\":[{\"env\":[{\"name\":\"PGDATA\",\"value\":\"/var/lib/postgresql/data/pgdata\"},{\"name\":\"POSTGRES_USER\",\"value\":\"***HIDDEN***\"},{\"name\":\"POSTGRES_PASSWORD\",\"valueFrom\":{\"secretKeyRef\":{\"key\":\"password\",\"name\":\"kotsadm-postgres\"}}},{\"name\":\"POSTGRES_DB\",\"value\":\"kotsadm\"}],\"image\":\"postgres:10.18-alpine\",\"livenessProbe\":{\"exec\":{\"command\":[\"/bin/sh\",\"-i\",\"-c\",\"pg_isready -U kotsadm -h ***HIDDEN*** -p 5432\"]},\"failureThreshold\":3,\"initialDelaySeconds\":30,\"timeoutSeconds\":5},\"name\":\"kotsadm-postgres\",\"ports\":[{\"containerPort\":5432,\"name\":\"postgres\"}],\"readinessProbe\":{\"exec\":{\"command\":[\"/bin/sh\",\"-i\",\"-c\",\"pg_isready -U kotsadm -h ***HIDDEN*** -p 5432\"]},\"initialDelaySeconds\":1,\"periodSeconds\":1,\"timeoutSeconds\":1},\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"200Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"mountPath\":\"/var/lib/postgresql/data\",\"name\":\"kotsadm-postgres\"},{\"mountPath\":\"/etc/passwd\",\"name\":\"etc-passwd\",\"subPath\":\"passwd\"}]}],\"securityContext\":{\"fsGroup\":999,\"runAsUser\":999},\"volumes\":[{\"name\":\"kotsadm-postgres\",\"persistentVolumeClaim\":{\"claimName\":\"kotsadm-postgres\"}},{\"configMap\":{\"items\":[{\"key\":\"passwd\",\"mode\":420,\"path\":\"passwd\"}],\"name\":\"kotsadm-postgres\"},\"name\":\"etc-passwd\"}]}},\"volumeClaimTemplates\":[{\"metadata\":{\"labels\":{\"kots.io/kotsadm\":\"true\"},\"name\":\"kotsadm-postgres\"},\"spec\":{\"accessModes\":[\"ReadWriteOnce\"],\"resources\":{\"requests\":{\"storage\":\"1Gi\"}}}}]}}\n"
},
"managedFields": [
{
"manager": "kubectl-client-side-apply",
"operation": "Update",
"apiVersion": "apps/v1",
"time": "2021-12-17T18:41:34Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:annotations": {
".": {},
"f:kubectl.kubernetes.io/last-applied-configuration": {}
},
"f:labels": {
".": {},
"f:kots.io/backup": {},
"f:kots.io/kotsadm": {}
}
},
"f:spec": {
"f:podManagementPolicy": {},
"f:replicas": {},
"f:revisionHistoryLimit": {},
"f:selector": {
"f:matchLabels": {
".": {},
"f:app": {}
}
},
"f:serviceName": {},
"f:template": {
"f:metadata": {
"f:labels": {
".": {},
"f:app": {},
"f:kots.io/backup": {},
"f:kots.io/kotsadm": {}
}
},
"f:spec": {
"f:containers": {
"k:{\"name\":\"kotsadm-postgres\"}": {
".": {},
"f:env": {
".": {},
"k:{\"name\":\"PGDATA\"}": {
".": {},
"f:name": {},
"f:value": {}
},
"k:{\"name\":\"POSTGRES_DB\"}": {
".": {},
"f:name": {},
"f:value": {}
},
"k:{\"name\":\"POSTGRES_PASSWORD\"}": {
".": {},
"f:name": {},
"f:valueFrom": {
".": {},
"f:secretKeyRef": {
".": {},
"f:key": {},
"f:name": {}
}
}
},
"k:{\"name\":\"POSTGRES_USER\"}": {
".": {},
"f:name": {},
"f:value": {}
}
},
"f:image": {},
"f:imagePullPolicy": {},
"f:livenessProbe": {
".": {},
"f:exec": {
".": {},
"f:command": {}
},
"f:failureThreshold": {},
"f:initialDelaySeconds": {},
"f:periodSeconds": {},
"f:successThreshold": {},
"f:timeoutSeconds": {}
},
"f:name": {},
"f:ports": {
".": {},
"k:{\"containerPort\":5432,\"protocol\":\"TCP\"}": {
".": {},
"f:containerPort": {},
"f:name": {},
"f:protocol": {}
}
},
"f:readinessProbe": {
".": {},
"f:exec": {
".": {},
"f:command": {}
},
"f:failureThreshold": {},
"f:initialDelaySeconds": {},
"f:periodSeconds": {},
"f:successThreshold": {},
"f:timeoutSeconds": {}
},
"f:resources": {
".": {},
"f:limits": {
".": {},
"f:cpu": {},
"f:memory": {}
},
"f:requests": {
".": {},
"f:cpu": {},
"f:memory": {}
}
},
"f:terminationMessagePath": {},
"f:terminationMessagePolicy": {},
"f:volumeMounts": {
".": {},
"k:{\"mountPath\":\"/etc/passwd\"}": {
".": {},
"f:mountPath": {},
"f:name": {},
"f:subPath": {}
},
"k:{\"mountPath\":\"/var/lib/postgresql/data\"}": {
".": {},
"f:mountPath": {},
"f:name": {}
}
}
}
},
"f:dnsPolicy": {},
"f:restartPolicy": {},
"f:schedulerName": {},
"f:securityContext": {
".": {},
"f:fsGroup": {},
"f:runAsUser": {}
},
"f:terminationGracePeriodSeconds": {},
"f:volumes": {
".": {},
"k:{\"name\":\"etc-passwd\"}": {
".": {},
"f:configMap": {
".": {},
"f:defaultMode": {},
"f:items": {},
"f:name": {}
},
"f:name": {}
},
"k:{\"name\":\"kotsadm-postgres\"}": {
".": {},
"f:name": {},
"f:persistentVolumeClaim": {
".": {},
"f:claimName": {}
}
}
}
}
},
"f:updateStrategy": {
"f:rollingUpdate": {
".": {},
"f:partition": {}
},
"f:type": {}
}
}
}
},
{
"manager": "kube-controller-manager",
"operation": "Update",
"apiVersion": "apps/v1",
"time": "2021-12-17T18:41:48Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:spec": {
"f:volumeClaimTemplates": {}
},
"f:status": {
"f:collisionCount": {},
"f:currentReplicas": {},
"f:currentRevision": {},
"f:observedGeneration": {},
"f:readyReplicas": {},
"f:replicas": {},
"f:updateRevision": {},
"f:updatedReplicas": {}
}
}
}
]
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"app": "kotsadm-postgres"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "kotsadm-postgres",
"kots.io/backup": "velero",
"kots.io/kotsadm": "true"
}
},
"spec": {
"volumes": [
{
"name": "kotsadm-postgres",
"persistentVolumeClaim": {
"claimName": "kotsadm-postgres"
}
},
{
"name": "etc-passwd",
"configMap": {
"name": "kotsadm-postgres",
"items": [
{
"key": "passwd",
"path": "passwd",
"mode": 420
}
],
"defaultMode": 420
}
}
],
"containers": [
{
"name": "kotsadm-postgres",
"image": "postgres:10.18-alpine",
"ports": [
{
"name": "postgres",
"containerPort": 5432,
"protocol": "TCP"
}
],
"env": [
{
"name": "PGDATA",
"value": "/var/lib/postgresql/data/pgdata"
},
{
"name": "POSTGRES_USER",
"value": "***HIDDEN***"
},
{
"name": "POSTGRES_PASSWORD",
"valueFrom": {
"secretKeyRef": {
"name": "kotsadm-postgres",
"key": "password"
}
}
},
{
"name": "POSTGRES_DB",
"value": "kotsadm"
}
],
"resources": {
"limits": {
"cpu": "200m",
"memory": "200Mi"
},
"requests": {
"cpu": "100m",
"memory": "100Mi"
}
},
"volumeMounts": [
{
"name": "kotsadm-postgres",
"mountPath": "/var/lib/postgresql/data"
},
{
"name": "etc-passwd",
"mountPath": "/etc/passwd",
"subPath": "passwd"
}
],
"livenessProbe": {
"exec": {
"command": [
"/bin/sh",
"-i",
"-c",
"pg_isready -U kotsadm -h ***HIDDEN*** -p 5432"
]
},
"initialDelaySeconds": 30,
"timeoutSeconds": 5,
"periodSeconds": 10,
"successThreshold": 1,
"failureThreshold": 3
},
"readinessProbe": {
"exec": {
"command": [
"/bin/sh",
"-i",
"-c",
"pg_isready -U kotsadm -h ***HIDDEN*** -p 5432"
]
},
"initialDelaySeconds": 1,
"timeoutSeconds": 1,
"periodSeconds": 1,
"successThreshold": 1,
"failureThreshold": 3
},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent"
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {
"runAsUser": 999,
"fsGroup": 999
},
"schedulerName": "default-scheduler"
}
},
"volumeClaimTemplates": [
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "kotsadm-postgres",
"creationTimestamp": null,
"labels": {
"kots.io/kotsadm": "true"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "1Gi"
}
},
"volumeMode": "Filesystem"
},
"status": {
"phase": "Pending"
}
}
],
"serviceName": "kotsadm-postgres",
"podManagementPolicy": "OrderedReady",
"updateStrategy": {
"type": "RollingUpdate",
"rollingUpdate": {
"partition": 0
}
},
"revisionHistoryLimit": 10
},
"status": {
"observedGeneration": 1,
"replicas": 2,
"readyReplicas": 1,
"currentReplicas": 1,
"updatedReplicas": 1,
"currentRevision": "kotsadm-postgres-77c87fd9d8",
"updateRevision": "kotsadm-postgres-77c87fd9d8",
"collisionCount": 0
}
}
]
}
File diff suppressed because it is too large Load Diff
+171
View File
@@ -0,0 +1,171 @@
package analyzer
import (
"fmt"
"path/filepath"
"reflect"
"strconv"
"github.com/pkg/errors"
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
iutils "github.com/replicatedhq/troubleshoot/pkg/interfaceutils"
"gopkg.in/yaml.v2"
)
var Filemap = map[string]string{
"Deployment": "deployments",
"StatefulSet": "statefulsets",
"NetworkPolicy": "network-policy",
"Pod": "pods",
"Ingress": "ingress",
"Service": "services",
"ResourceQuota": "resource-quotas",
"Job": "jobs",
"PersistentVoumeClaim": "pvcs",
"pvc": "pvcs",
"ReplicaSet": "replicasets",
"Namespace": "namespaces.json",
"PersistentVolume": "pvs.json",
"pv": "pvs.json",
"Node": "nodes.json",
"StorageClass": "storage-classes.json",
}
// FindResource locates and returns a kubernetes resource as an interface{} from a support bundle based on some basic selectors
// if clusterScoped is false and namespace is not provided, it will default to looking in the "default" namespace
func FindResource(kind string, clusterScoped bool, namespace string, name string, getFileContents getCollectedFileContents) (interface{}, error) {
var datapath string
resourceLocation, ok := Filemap[kind]
if !ok {
return nil, errors.New("failed to find resource")
}
datapath = filepath.Join("cluster-resources", resourceLocation)
if !clusterScoped {
if namespace == "" {
namespace = "default"
}
datapath = filepath.Join("cluster-resources", resourceLocation, fmt.Sprintf("%s.json", namespace))
}
file, err := getFileContents(datapath)
if err != nil {
return nil, errors.Wrap(err, "failed to read collected resources")
}
var resource interface{}
err = yaml.Unmarshal(file, &resource)
if err != nil {
return nil, errors.Wrap(err, "failed to parse data as yaml doc")
}
items, err := iutils.GetAtPath(resource, "items")
if err != nil {
return nil, errors.Wrap(err, "failed to get items from file")
}
itemslice := items.([]interface{})
for _, item := range itemslice {
name, err := iutils.GetAtPath(item, "metadata.name")
if err != nil {
return nil, errors.Wrapf(err, "Failed to find resource with name: %s", name)
}
if name == name {
return item, nil
}
}
return nil, nil
}
func analyzeResource(analyzer *troubleshootv1beta2.ClusterResource, getFileContents getCollectedFileContents) (*AnalyzeResult, error) {
selected, err := FindResource(analyzer.Kind, analyzer.ClusterScoped, analyzer.Namespace, analyzer.Name, getFileContents)
if err != nil {
return nil, errors.Wrap(err, "failed to find resource")
}
actual, err := iutils.GetAtPath(selected, analyzer.YamlPath)
if err != nil {
return nil, errors.Wrapf(err, "failed to get object at path: %s", analyzer.YamlPath)
}
var expected interface{}
err = yaml.Unmarshal([]byte(analyzer.ExpectedValue), &expected)
if err != nil {
return nil, errors.Wrap(err, "failed to parse expected value as yaml doc")
}
title := analyzer.CheckName
if title == "" {
title = analyzer.CollectorName
}
result := &AnalyzeResult{
Title: title,
IconKey: "kubernetes_text_analyze",
IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg",
}
equal := reflect.DeepEqual(actual, expected)
for _, outcome := range analyzer.Outcomes {
if outcome.Fail != nil {
when := false
if outcome.Fail.When != "" {
when, err = strconv.ParseBool(outcome.Fail.When)
if err != nil {
return nil, errors.Wrapf(err, "failed to process when statement: %s", outcome.Fail.When)
}
}
if when == equal {
result.IsFail = true
result.Message = outcome.Fail.Message
result.URI = outcome.Fail.URI
return result, nil
}
} else if outcome.Warn != nil {
when := false
if outcome.Warn.When != "" {
when, err = strconv.ParseBool(outcome.Warn.When)
if err != nil {
return nil, errors.Wrapf(err, "failed to process when statement: %s", outcome.Warn.When)
}
}
if when == equal {
result.IsWarn = true
result.Message = outcome.Warn.Message
result.URI = outcome.Warn.URI
return result, nil
}
} else if outcome.Pass != nil {
when := true // default to passing when values are equal
if outcome.Pass.When != "" {
when, err = strconv.ParseBool(outcome.Pass.When)
if err != nil {
return nil, errors.Wrapf(err, "failed to process when statement: %s", outcome.Pass.When)
}
}
if when == equal {
result.IsPass = true
result.Message = outcome.Pass.Message
result.URI = outcome.Pass.URI
return result, nil
}
}
}
return &AnalyzeResult{
Title: title,
IconKey: "kubernetes_text_analyze",
IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg",
IsFail: true,
Message: "Invalid analyzer",
}, nil
}
+57
View File
@@ -0,0 +1,57 @@
package analyzer
import (
"path/filepath"
"testing"
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
"github.com/stretchr/testify/assert"
)
func Test_clusterResource(t *testing.T) {
tests := []struct {
name string
isError bool
analyzer troubleshootv1beta2.ClusterResource
}{
{
name: "namespaced resource",
analyzer: troubleshootv1beta2.ClusterResource{
CollectorName: "Check namespaced resource",
Kind: "Deployment",
Namespace: "kube-system",
Name: "coredns",
},
},
{
name: "check default fallthrough",
analyzer: troubleshootv1beta2.ClusterResource{
CollectorName: "Check namespaced resource",
Kind: "Deployment",
Name: "kotsadm-api",
},
},
{
name: "cluster scoped resource",
analyzer: troubleshootv1beta2.ClusterResource{
CollectorName: "Check namespaced resource",
Kind: "Node",
ClusterScoped: true,
Name: "repldev-marc",
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
rootDir := filepath.Join("files", "support-bundle")
fcp := fileContentProvider{rootDir: rootDir}
analyzer := &test.analyzer
_, err := FindResource(analyzer.Kind, analyzer.ClusterScoped, analyzer.Namespace, analyzer.Name, fcp.getFileContents)
assert.Nil(t, err)
})
}
}
@@ -58,6 +58,18 @@ type DeploymentStatus struct {
Name string `json:"name" yaml:"name"`
}
type ClusterResource struct {
AnalyzeMeta `json:",inline" yaml:",inline"`
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
Kind string `json:"kind" yaml:"kind"`
ClusterScoped bool `json:"clusterScoped" yaml:"clusterScoped"`
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
Name string `json:"name" yaml:"name"`
YamlPath string `json:"yamlPath" yaml:"yamlPath"`
ExpectedValue string `json:"expectedValue,omitempty" yaml:"expectedValue,omitempty"`
}
type StatefulsetStatus struct {
AnalyzeMeta `json:",inline" yaml:",inline"`
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
@@ -227,4 +239,5 @@ type Analyze struct {
RegistryImages *RegistryImagesAnalyze `json:"registryImages,omitempty" yaml:"registryImages,omitempty"`
WeaveReport *WeaveReportAnalyze `json:"weaveReport,omitempty" yaml:"weaveReport,omitempty"`
Sysctl *SysctlAnalyze `json:"sysctl,omitempty" yaml:"sysctl,omitempty"`
ClusterResource *ClusterResource `json:"clusterResource,omitempty" yaml:"clusterResource,omitempty"`
}
@@ -184,6 +184,11 @@ func (in *Analyze) DeepCopyInto(out *Analyze) {
*out = new(SysctlAnalyze)
(*in).DeepCopyInto(*out)
}
if in.ClusterResource != nil {
in, out := &in.ClusterResource, &out.ClusterResource
*out = new(ClusterResource)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Analyze.
@@ -597,6 +602,33 @@ func (in *ClusterPodStatuses) DeepCopy() *ClusterPodStatuses {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterResource) DeepCopyInto(out *ClusterResource) {
*out = *in
in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta)
if in.Outcomes != nil {
in, out := &in.Outcomes, &out.Outcomes
*out = make([]*Outcome, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(Outcome)
(*in).DeepCopyInto(*out)
}
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterResource.
func (in *ClusterResource) DeepCopy() *ClusterResource {
if in == nil {
return nil
}
out := new(ClusterResource)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterResources) DeepCopyInto(out *ClusterResources) {
*out = *in
@@ -181,6 +181,104 @@
}
}
},
"clusterResource": {
"type": "object",
"required": [
"clusterScoped",
"kind",
"name",
"outcomes",
"yamlPath"
],
"properties": {
"annotations": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"checkName": {
"type": "string"
},
"clusterScoped": {
"type": "boolean"
},
"collectorName": {
"type": "string"
},
"exclude": {
"oneOf": [{"type": "string"},{"type": "boolean"}]
},
"expectedValue": {
"type": "string"
},
"kind": {
"type": "string"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
},
"strict": {
"oneOf": [{"type": "string"},{"type": "boolean"}]
},
"yamlPath": {
"type": "string"
}
}
},
"clusterVersion": {
"type": "object",
"required": [
@@ -181,6 +181,104 @@
}
}
},
"clusterResource": {
"type": "object",
"required": [
"clusterScoped",
"kind",
"name",
"outcomes",
"yamlPath"
],
"properties": {
"annotations": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"checkName": {
"type": "string"
},
"clusterScoped": {
"type": "boolean"
},
"collectorName": {
"type": "string"
},
"exclude": {
"oneOf": [{"type": "string"},{"type": "boolean"}]
},
"expectedValue": {
"type": "string"
},
"kind": {
"type": "string"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
},
"strict": {
"oneOf": [{"type": "string"},{"type": "boolean"}]
},
"yamlPath": {
"type": "string"
}
}
},
"clusterVersion": {
"type": "object",
"required": [
@@ -227,6 +227,104 @@
}
}
},
"clusterResource": {
"type": "object",
"required": [
"clusterScoped",
"kind",
"name",
"outcomes",
"yamlPath"
],
"properties": {
"annotations": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"checkName": {
"type": "string"
},
"clusterScoped": {
"type": "boolean"
},
"collectorName": {
"type": "string"
},
"exclude": {
"oneOf": [{"type": "string"},{"type": "boolean"}]
},
"expectedValue": {
"type": "string"
},
"kind": {
"type": "string"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fail": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"pass": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
},
"warn": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"uri": {
"type": "string"
},
"when": {
"type": "string"
}
}
}
}
}
},
"strict": {
"oneOf": [{"type": "string"},{"type": "boolean"}]
},
"yamlPath": {
"type": "string"
}
}
},
"clusterVersion": {
"type": "object",
"required": [