From 77afe848cdd64bd55bfc2c77a7ec431221537273 Mon Sep 17 00:00:00 2001 From: yair Date: Tue, 26 Dec 2023 18:18:15 +0200 Subject: [PATCH 1/5] k8s install script --- kubernetes/argo_config.tmpl | 16 ++--- kubernetes/argo_rollouts_config.tmpl | 4 +- .../kubernetes_kantive_usecase.yaml | 60 +++++++++--------- .../full-configs/lean_kubernetes_usecase.yaml | 20 +++--- .../full-configs/openshift_usecase.yaml | 54 ++++++++-------- kubernetes/install.sh | 28 +++------ kubernetes/kubernetes_config.yaml | 38 ++++++------ kubernetes/kubernetes_v1_config.yaml | 42 ++++++------- ...o_rollouts-istio-kubernetes_v1_config.yaml | 62 +++++++++---------- ...go-argo_rollouts-kubernetes_v1_config.yaml | 62 +++++++++---------- .../argo-istio-kubernetes_v1_config.yaml | 58 ++++++++--------- .../templates/argo-kubernetes_v1_config.yaml | 58 ++++++++--------- .../templates/istio-kubernetes_v1_config.yaml | 42 ++++++------- .../templates/kubernetes_v1_config.yaml | 42 ++++++------- 14 files changed, 288 insertions(+), 298 deletions(-) diff --git a/kubernetes/argo_config.tmpl b/kubernetes/argo_config.tmpl index cf28e5e..ae9c2f9 100644 --- a/kubernetes/argo_config.tmpl +++ b/kubernetes/argo_config.tmpl @@ -3,7 +3,7 @@ port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME blueprint: '"argocdApp"' title: .metadata.name properties: @@ -14,20 +14,20 @@ gitPath: .spec.source.path // null gitRev: .status.sync.revision // null relations: - workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-{CLUSTER_NAME}") // []' - argocdProject: .spec.project + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - destinationNamespace: .spec.destination.namespace + "-" + "{CLUSTER_NAME}" + workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-" + env.CLUSTER_NAME) // []' + argocdProject: .spec.project + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + destinationNamespace: .spec.destination.namespace + "-" + env.CLUSTER_NAME - kind: argoproj.io/v1alpha1/appproject port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"argocdProject"' properties: relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: v1/secrets selector: @@ -35,11 +35,11 @@ port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"argocdRepo"' properties: repoUrl: .data.url | @base64d repoType: .data.type | @base64d relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME diff --git a/kubernetes/argo_rollouts_config.tmpl b/kubernetes/argo_rollouts_config.tmpl index 42c54f9..2566001 100644 --- a/kubernetes/argo_rollouts_config.tmpl +++ b/kubernetes/argo_rollouts_config.tmpl @@ -5,7 +5,7 @@ port: entity: mappings: - - identifier: .metadata.name + "-Rollout-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Rollout-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -21,4 +21,4 @@ containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME diff --git a/kubernetes/full-configs/kubernetes_kantive_usecase.yaml b/kubernetes/full-configs/kubernetes_kantive_usecase.yaml index aae0555..f97c37f 100644 --- a/kubernetes/full-configs/kubernetes_kantive_usecase.yaml +++ b/kubernetes/full-configs/kubernetes_kantive_usecase.yaml @@ -5,14 +5,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME # Defines cluster using the uniq @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: '"{CLUSTER_NAME}"' - title: '"{CLUSTER_NAME}"' + - identifier: env.CLUSTER_NAME + title: env.CLUSTER_NAME blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/replicasets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -75,9 +75,9 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - workloadManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // null - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - knativeRevision: 'if (.metadata.ownerReferences[0].kind == "Revision") then .metadata.ownerReferences[0].name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" else null end' + workloadManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // null + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + knativeRevision: 'if (.metadata.ownerReferences[0].kind == "Revision") then .metadata.ownerReferences[0].name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME else null end' - kind: apps/v1/daemonsets selector: @@ -85,7 +85,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -101,8 +101,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - knativeRevision: 'if (.metadata.ownerReferences[0].kind == "Revision") then .metadata.ownerReferences[0].name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" else null end' + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + knativeRevision: 'if (.metadata.ownerReferences[0].kind == "Revision") then .metadata.ownerReferences[0].name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME else null end' - kind: apps/v1/statefulsets selector: @@ -110,7 +110,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -126,7 +126,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: v1/pods selector: @@ -134,7 +134,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -145,15 +145,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - title: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + title: .metadata.name + "-" + env.CLUSTER_NAME icon: '"Node"' blueprint: '"node"' properties: @@ -164,7 +164,7 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME - kind: serving.knative.dev/v1/service selector: @@ -172,7 +172,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"knativeService"' properties: @@ -186,7 +186,7 @@ resources: # List of K8s resources to list, watch, and export to Port. ready: .status.conditions[] | select(.type == "Ready") | .status generation: .metadata.generation relations: - namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: serving.knative.dev/v1/configuration selector: @@ -194,7 +194,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"knativeConfiguration"' properties: @@ -203,7 +203,7 @@ resources: # List of K8s resources to list, watch, and export to Port. ready: .status.conditions[] | select(.type == "Ready") | .status containers: .spec.template.spec.containers relations: - knativeService: .metadata.ownerReferences[0].name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + knativeService: .metadata.ownerReferences[0].name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - kind: serving.knative.dev/v1/revision selector: @@ -211,7 +211,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"knativeRevision"' properties: @@ -221,7 +221,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: .spec.containers replicaCount: .status.actualReplicas relations: - knativeConfiguration: .metadata.ownerReferences[0].name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + knativeConfiguration: .metadata.ownerReferences[0].name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - kind: serving.knative.dev/v1/route selector: @@ -229,7 +229,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"knativeRoute"' properties: @@ -238,5 +238,5 @@ resources: # List of K8s resources to list, watch, and export to Port. trafficConfiguration: .status.traffic url: .status.url relations: - knativeRevision: '[.status.traffic[].revisionName + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}"]' - knativeService: .metadata.ownerReferences[0].name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + knativeRevision: '[.status.traffic[].revisionName + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME]' + knativeService: .metadata.ownerReferences[0].name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME diff --git a/kubernetes/full-configs/lean_kubernetes_usecase.yaml b/kubernetes/full-configs/lean_kubernetes_usecase.yaml index c676e44..fb28651 100644 --- a/kubernetes/full-configs/lean_kubernetes_usecase.yaml +++ b/kubernetes/full-configs/lean_kubernetes_usecase.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: '"{CLUSTER_NAME}"' - title: '"{CLUSTER_NAME}"' + - identifier: env.CLUSTER_NAME + title: env.CLUSTER_NAME blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -98,4 +98,4 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" \ No newline at end of file + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME \ No newline at end of file diff --git a/kubernetes/full-configs/openshift_usecase.yaml b/kubernetes/full-configs/openshift_usecase.yaml index 5427bfe..39c3acb 100644 --- a/kubernetes/full-configs/openshift_usecase.yaml +++ b/kubernetes/full-configs/openshift_usecase.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: '"{CLUSTER_NAME}"' - title: '"{CLUSTER_NAME}"' + - identifier: env.CLUSTER_NAME + title: env.CLUSTER_NAME blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - title: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + title: .metadata.name + "-" + env.CLUSTER_NAME icon: '"Node"' blueprint: '"node"' properties: @@ -183,7 +183,7 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME - kind: route.openshift.io/v1/routes selector: @@ -191,14 +191,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - title: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + title: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME blueprint: '"openshiftRoute"' properties: hostname: .spec.host spec: .spec relations: - service: .metadata.namespace as $namespace | [(.spec.alternateBackends[]?.name )] as $alt_backends | ($alt_backends + [.spec.to.name]) | map(. + "-" + $namespace + "-" + "{CLUSTER_NAME}") + service: .metadata.namespace as $namespace | [(.spec.alternateBackends[]?.name )] as $alt_backends | ($alt_backends + [.spec.to.name]) | map(. + "-" + $namespace + "-" + env.CLUSTER_NAME) - kind: v1/services selector: @@ -206,7 +206,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Service"' blueprint: '"k8sService"' @@ -222,7 +222,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.labels."kubernetes.io/service-name" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.labels."kubernetes.io/service-name" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME blueprint: '"k8sService"' relations: - pods: .metadata.namespace as $namespace | ([.endpoints[].targetRef.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}"]) \ No newline at end of file + pods: .metadata.namespace as $namespace | ([.endpoints[].targetRef.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME]) \ No newline at end of file diff --git a/kubernetes/install.sh b/kubernetes/install.sh index 23fec22..0d2d31d 100644 --- a/kubernetes/install.sh +++ b/kubernetes/install.sh @@ -8,7 +8,7 @@ set -e # Version: v1.0 # # Description: -# This script is responsible for installing Port's Kuberenetes exporter using helm. +# This script is responsible for installing Port's Kubernetes exporter using helm. # Documentation: https://docs.getport.io/build-your-software-catalog/sync-data-to-catalog/kubernetes/) # # Prerequisites(https://docs.getport.io/build-your-software-catalog/sync-data-to-catalog/kubernetes/#prerequisites): @@ -30,7 +30,6 @@ REPO_BASE_URL="https://raw.githubusercontent.com/port-labs/template-assets/${REP COMMON_FUNCTIONS_URL="${REPO_BASE_URL}/common.sh" # Exporter installation variables -TEMPLATE_NAME=${TEMPLATE_NAME:-} BASE_CONFIG_YAML_URL="$REPO_BASE_URL/kubernetes/kubernetes_config.yaml" CONFIG_YAML_URL=${CONFIG_YAML_URL:-} CUSTOM_BP_PATH=${CUSTOM_BP_PATH:-} @@ -77,17 +76,8 @@ echo "" # Download config.yaml file into temporary folder if [[ -z ${CONFIG_YAML_URL} ]]; then - save_endpoint_to_file ${BASE_CONFIG_YAML_URL} "${temp_dir}/template_config.yaml" - - # Iterate over TEMPLATE_NAMES and download their config.yaml files - for template in ${TEMPLATE_NAME} - do - echo "Downloading config.tmpl file for template '${template}'..." - CONFIG_YAML_URL="${REPO_BASE_URL}/kubernetes/${template}_config.tmpl" - save_endpoint_to_file ${CONFIG_YAML_URL} "${temp_dir}/${template}_config.tmpl" - cat ${temp_dir}/${template}_config.tmpl >> ${temp_dir}/template_config.yaml - echo "Added ${template}." - done + echo "No custom config.yaml file configuration found. Please spciy a custom config.yaml file using the 'CONFIG_YAML_URL' variable." + exit 1 else echo "Custom config.yaml file configuration found." config_path_type=$(check_path_or_url ${CONFIG_YAML_URL}) # 'local' or 'url' @@ -100,9 +90,8 @@ else exit 1 fi fi +# Validate config.yaml is a valid yaml (cat ${temp_dir}/template_config.yaml | yq > /dev/null) || (echo "Failed to 'yq' parse the config.yaml. Is it a valid yaml? Exiting..." && exit 1) -# Replace the place holder {CLUSTER_NAME} with passed cluster name in the config.yaml -sed "s/{CLUSTER_NAME}/${CLUSTER_NAME}/g" "${temp_dir}/template_config.yaml" > "${temp_dir}/config.yaml" echo "" if [[ ! -z ${CUSTOM_BP_PATH} ]]; then @@ -138,10 +127,11 @@ echo "" echo "The exporter will be deployed to namespace: '${TARGET_NAMESPACE}', under the deployment name '${DEPLOYMENT_NAME}'." echo "" helm upgrade --install ${DEPLOYMENT_NAME} ${HELM_REPO_NAME}/${HELM_K8S_CHART_NAME} \ ---create-namespace --namespace ${TARGET_NAMESPACE} \ ---set secret.secrets.portClientId=${PORT_CLIENT_ID} --set secret.secrets.portClientSecret=${PORT_CLIENT_SECRET} \ ---set-file configMap.config=${temp_dir}/config.yaml \ ---set stateKey=${CLUSTER_NAME} + --create-namespace --namespace ${TARGET_NAMESPACE} \ + --set secret.secrets.portClientId=${PORT_CLIENT_ID} --set secret.secrets.portClientSecret=${PORT_CLIENT_SECRET} \ + --set extraEnv[0]={"name": "CLUSTER_NAME", "value": "${CLUSTER_NAME}"} \ + --set extraEnv[1]={"name": "CREATE_DEFAULT_RESOURCES", "value": "false"} \ + --set stateKey=${CLUSTER_NAME} echo "" echo "Finished installation!" diff --git a/kubernetes/kubernetes_config.yaml b/kubernetes/kubernetes_config.yaml index 025f044..362ab12 100644 --- a/kubernetes/kubernetes_config.yaml +++ b/kubernetes/kubernetes_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: '"{CLUSTER_NAME}"' - title: '"{CLUSTER_NAME}"' + - identifier: env.CLUSTER_NAME + title: env.CLUSTER_NAME blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -107,7 +107,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -118,8 +118,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: '(.metadata.ownerReferences[0].name | split("-") | .[:-1] | join("-")) + "-" + "Deployment" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}"' - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + workload: '(.metadata.ownerReferences[0].name | split("-") | .[:-1] | join("-")) + "-" + "Deployment" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME' + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) - kind: v1/pods @@ -128,7 +128,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -139,15 +139,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - title: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + title: .metadata.name + "-" + env.CLUSTER_NAME icon: '"Node"' blueprint: '"node"' properties: @@ -158,4 +158,4 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME diff --git a/kubernetes/kubernetes_v1_config.yaml b/kubernetes/kubernetes_v1_config.yaml index 66bb30c..f4c80ff 100644 --- a/kubernetes/kubernetes_v1_config.yaml +++ b/kubernetes/kubernetes_v1_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: 'env.CLUSTER_NAME' - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: '"{CLUSTER_NAME}"' - title: '"{CLUSTER_NAME}"' + - identifier: env.CLUSTER_NAME + title: env.CLUSTER_NAME blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - title: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + title: .metadata.name + "-" + env.CLUSTER_NAME icon: '"Node"' blueprint: '"node"' properties: @@ -183,4 +183,4 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME diff --git a/kubernetes/templates/argo-argo_rollouts-istio-kubernetes_v1_config.yaml b/kubernetes/templates/argo-argo_rollouts-istio-kubernetes_v1_config.yaml index 1de9c1e..b25a58f 100644 --- a/kubernetes/templates/argo-argo_rollouts-istio-kubernetes_v1_config.yaml +++ b/kubernetes/templates/argo-argo_rollouts-istio-kubernetes_v1_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: '"{CLUSTER_NAME}"' - title: '"{CLUSTER_NAME}"' + - identifier: env.CLUSTER_NAME + title: env.CLUSTER_NAME blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - title: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + title: .metadata.name + "-" + env.CLUSTER_NAME icon: '"Node"' blueprint: '"node"' properties: @@ -183,14 +183,14 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME # ArgoCD configuration - kind: argoproj.io/v1alpha1/applications port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME blueprint: '"argocdApp"' title: .metadata.name properties: @@ -201,20 +201,20 @@ resources: # List of K8s resources to list, watch, and export to Port. gitPath: .spec.source.path // null gitRev: .status.sync.revision // null relations: - workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-{CLUSTER_NAME}") // []' - argocdProject: .spec.project + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - destinationNamespace: .spec.destination.namespace + "-" + "{CLUSTER_NAME}" + workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-" + env.CLUSTER_NAME) // []' + argocdProject: .spec.project + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + destinationNamespace: .spec.destination.namespace + "-" + env.CLUSTER_NAME - kind: argoproj.io/v1alpha1/appproject port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"argocdProject"' properties: relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: v1/secrets selector: @@ -222,14 +222,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"argocdRepo"' properties: repoUrl: .data.url | @base64d repoType: .data.type | @base64d relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME # ArgoCD Rollouts configuration - kind: argoproj.io/v1alpha1/rollouts @@ -238,7 +238,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Rollout-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Rollout-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -254,7 +254,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: networking.istio.io/v1beta1/virtualservices port: diff --git a/kubernetes/templates/argo-argo_rollouts-kubernetes_v1_config.yaml b/kubernetes/templates/argo-argo_rollouts-kubernetes_v1_config.yaml index 5609125..427b5ee 100644 --- a/kubernetes/templates/argo-argo_rollouts-kubernetes_v1_config.yaml +++ b/kubernetes/templates/argo-argo_rollouts-kubernetes_v1_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: 'env.CLUSTER_NAME' - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: '"{CLUSTER_NAME}"' - title: '"{CLUSTER_NAME}"' + - identifier: env.CLUSTER_NAME + title: env.CLUSTER_NAME blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - title: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + title: .metadata.name + "-" + env.CLUSTER_NAME icon: '"Node"' blueprint: '"node"' properties: @@ -183,14 +183,14 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME # ArgoCD configuration - kind: argoproj.io/v1alpha1/applications port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME blueprint: '"argocdApp"' title: .metadata.name properties: @@ -201,20 +201,20 @@ resources: # List of K8s resources to list, watch, and export to Port. gitPath: .spec.source.path // null gitRev: .status.sync.revision // null relations: - workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-{CLUSTER_NAME}") // []' - argocdProject: .spec.project + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - destinationNamespace: .spec.destination.namespace + "-" + "{CLUSTER_NAME}" + workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-" + env.CLUSTER_NAME) // []' + argocdProject: .spec.project + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + destinationNamespace: .spec.destination.namespace + "-" + env.CLUSTER_NAME - kind: argoproj.io/v1alpha1/appproject port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"argocdProject"' properties: relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: v1/secrets selector: @@ -222,14 +222,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"argocdRepo"' properties: repoUrl: .data.url | @base64d repoType: .data.type | @base64d relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME # ArgoCD Rollouts configuration - kind: argoproj.io/v1alpha1/rollouts @@ -238,7 +238,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Rollout-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Rollout-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -254,4 +254,4 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME diff --git a/kubernetes/templates/argo-istio-kubernetes_v1_config.yaml b/kubernetes/templates/argo-istio-kubernetes_v1_config.yaml index 535be85..642eda3 100644 --- a/kubernetes/templates/argo-istio-kubernetes_v1_config.yaml +++ b/kubernetes/templates/argo-istio-kubernetes_v1_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: '"{CLUSTER_NAME}"' - title: '"{CLUSTER_NAME}"' + - identifier: env.CLUSTER_NAME + title: env.CLUSTER_NAME blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - title: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + title: .metadata.name + "-" + env.CLUSTER_NAME icon: '"Node"' blueprint: '"node"' properties: @@ -183,14 +183,14 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME # ArgoCD configuration - kind: argoproj.io/v1alpha1/applications port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME blueprint: '"argocdApp"' title: .metadata.name properties: @@ -201,20 +201,20 @@ resources: # List of K8s resources to list, watch, and export to Port. gitPath: .spec.source.path // null gitRev: .status.sync.revision // null relations: - workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-{CLUSTER_NAME}") // []' - argocdProject: .spec.project + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - destinationNamespace: .spec.destination.namespace + "-" + "{CLUSTER_NAME}" + workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-" + env.CLUSTER_NAME) // []' + argocdProject: .spec.project + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + destinationNamespace: .spec.destination.namespace + "-" + env.CLUSTER_NAME - kind: argoproj.io/v1alpha1/appproject port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"argocdProject"' properties: relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: v1/secrets selector: @@ -222,14 +222,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"argocdRepo"' properties: repoUrl: .data.url | @base64d repoType: .data.type | @base64d relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: networking.istio.io/v1beta1/virtualservices port: diff --git a/kubernetes/templates/argo-kubernetes_v1_config.yaml b/kubernetes/templates/argo-kubernetes_v1_config.yaml index 979053e..2a7a4b3 100644 --- a/kubernetes/templates/argo-kubernetes_v1_config.yaml +++ b/kubernetes/templates/argo-kubernetes_v1_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: '"{CLUSTER_NAME}"' - title: '"{CLUSTER_NAME}"' + - identifier: env.CLUSTER_NAME + title: 'env.CLUSTER_NAME' blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - title: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + title: .metadata.name + "-" + env.CLUSTER_NAME icon: '"Node"' blueprint: '"node"' properties: @@ -183,14 +183,14 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME # ArgoCD configuration - kind: argoproj.io/v1alpha1/applications port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME blueprint: '"argocdApp"' title: .metadata.name properties: @@ -201,20 +201,20 @@ resources: # List of K8s resources to list, watch, and export to Port. gitPath: .spec.source.path // null gitRev: .status.sync.revision // null relations: - workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-{CLUSTER_NAME}") // []' - argocdProject: .spec.project + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - destinationNamespace: .spec.destination.namespace + "-" + "{CLUSTER_NAME}" + workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-" + env.CLUSTER_NAME) // []' + argocdProject: .spec.project + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + destinationNamespace: .spec.destination.namespace + "-" + env.CLUSTER_NAME - kind: argoproj.io/v1alpha1/appproject port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"argocdProject"' properties: relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: v1/secrets selector: @@ -222,11 +222,11 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"argocdRepo"' properties: repoUrl: .data.url | @base64d repoType: .data.type | @base64d relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME diff --git a/kubernetes/templates/istio-kubernetes_v1_config.yaml b/kubernetes/templates/istio-kubernetes_v1_config.yaml index fa6c433..248a670 100644 --- a/kubernetes/templates/istio-kubernetes_v1_config.yaml +++ b/kubernetes/templates/istio-kubernetes_v1_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: 'env.CLUSTER_NAME' - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: '"{CLUSTER_NAME}"' - title: '"{CLUSTER_NAME}"' + - identifier: env.CLUSTER_NAME + title: env.CLUSTER_NAME blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - title: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + title: .metadata.name + "-" + env.CLUSTER_NAME icon: '"Node"' blueprint: '"node"' properties: @@ -183,7 +183,7 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: 'env.CLUSTER_NAME' - kind: networking.istio.io/v1beta1/virtualservices port: diff --git a/kubernetes/templates/kubernetes_v1_config.yaml b/kubernetes/templates/kubernetes_v1_config.yaml index 66bb30c..8c822bf 100644 --- a/kubernetes/templates/kubernetes_v1_config.yaml +++ b/kubernetes/templates/kubernetes_v1_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: '"{CLUSTER_NAME}"' - title: '"{CLUSTER_NAME}"' + - identifier: env.CLUSTER_NAME + title: env.CLUSTER_NAME blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" + Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - title: .metadata.name + "-" + "{CLUSTER_NAME}" + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + title: .metadata.name + "-" + env.CLUSTER_NAME icon: '"Node"' blueprint: '"node"' properties: @@ -183,4 +183,4 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: '"{CLUSTER_NAME}"' + Cluster: env.CLUSTER_NAME From c409b7210fb0526f1c45a61a42ffa73ff6936850 Mon Sep 17 00:00:00 2001 From: yair Date: Tue, 26 Dec 2023 18:35:13 +0200 Subject: [PATCH 2/5] removed unused var --- kubernetes/install.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/kubernetes/install.sh b/kubernetes/install.sh index 0d2d31d..2340afd 100644 --- a/kubernetes/install.sh +++ b/kubernetes/install.sh @@ -26,11 +26,9 @@ set -e # Global variables REPO_BRANCH=${REPO_BRANCH:-"main"} -REPO_BASE_URL="https://raw.githubusercontent.com/port-labs/template-assets/${REPO_BRANCH}" COMMON_FUNCTIONS_URL="${REPO_BASE_URL}/common.sh" # Exporter installation variables -BASE_CONFIG_YAML_URL="$REPO_BASE_URL/kubernetes/kubernetes_config.yaml" CONFIG_YAML_URL=${CONFIG_YAML_URL:-} CUSTOM_BP_PATH=${CUSTOM_BP_PATH:-} HELM_REPO_NAME="port-labs" From d5ab09fe5b7cc4b9d08b0f3a726e9bb37aaf1a20 Mon Sep 17 00:00:00 2001 From: yair Date: Thu, 28 Dec 2023 15:16:05 +0200 Subject: [PATCH 3/5] k8s installation fixes --- kubernetes/blueprints/istio-blueprints.json | 805 +++++++++++--------- kubernetes/install.sh | 6 +- 2 files changed, 444 insertions(+), 367 deletions(-) diff --git a/kubernetes/blueprints/istio-blueprints.json b/kubernetes/blueprints/istio-blueprints.json index c1757e3..aa7dafe 100644 --- a/kubernetes/blueprints/istio-blueprints.json +++ b/kubernetes/blueprints/istio-blueprints.json @@ -1,379 +1,454 @@ [ - { - "identifier":"cluster", - "description":"This blueprint represents a Kubernetes Cluster", - "title":"Cluster", - "icon":"Cluster", - "schema":{ - "properties":{ - - }, - "required":[ - - ] - }, - "mirrorProperties":{ - - }, - "calculationProperties":{ - - }, - "relations":{ - - } + { + "identifier": "cluster", + "description": "This blueprint represents a Kubernetes Cluster", + "title": "Cluster", + "icon": "Cluster", + "schema": { + "properties": { + }, + "required": [ + ] }, - { - "identifier":"node", - "description":"This blueprint represents a k8s Node", - "title":"Node", - "icon":"Node", - "schema":{ - "properties":{ - "creationTimestamp":{ - "type":"string", - "icon":"DeployedAt", - "title":"Created", - "format":"date-time", - "description":"When the Node was created (added to the cluster)" - }, - "labels":{ - "type":"object", - "title":"Labels", - "description":"Labels of the Node" - }, - "ready":{ - "type":"string", - "title":"Node Readiness", - "description":"Node ready status", - "enum":[ - "True", - "False" - ], - "enumColors":{ - "False":"red", - "True":"green" - } - }, - "totalMemory":{ - "type":"string", - "icon":"GPU", - "title":"Total Memory (kibibytes)", - "description":"Total memory capacity of the Node" - }, - "kubeletVersion":{ - "type":"string", - "title":"Kubelet Version", - "description":"The node's kubelet version" - }, - "totalCPU":{ - "type":"string", - "icon":"CPU", - "title":"Total CPU (milli-cores)", - "description":"Total CPU capacity of the Node" - } - }, - "required":[ - - ] - }, - "mirrorProperties":{ - - }, - "calculationProperties":{ - - }, - "relations":{ - "Cluster":{ - "title":"Cluster", - "target":"cluster", - "required":false, - "many":true - } - } + "mirrorProperties": { }, - { - "identifier":"namespace", - "description":"This blueprint represents a k8s Namespace", - "title":"Namespace", - "icon":"Environment", - "schema":{ - "properties":{ - "creationTimestamp":{ - "type":"string", - "title":"Created", - "format":"date-time", - "description":"When the Namespace was created" - }, - "labels":{ - "type":"object", - "title":"Labels", - "description":"Labels of the Namespace" - } - }, - "required":[ - - ] - }, - "mirrorProperties":{ - - }, - "calculationProperties":{ - - }, - "relations":{ - "Cluster":{ - "title":"Cluster", - "description":"The namespace's Kubernetes cluster", - "target":"cluster", - "required":false, - "many":false + "calculationProperties": { + }, + "relations": { + } + }, + { + "identifier": "node", + "description": "This blueprint represents a k8s Node", + "title": "Node", + "icon": "Node", + "schema": { + "properties": { + "creationTimestamp": { + "type": "string", + "icon": "DeployedAt", + "title": "Created", + "format": "date-time", + "description": "When the Node was created (added to the cluster)" + }, + "labels": { + "type": "object", + "title": "Labels", + "description": "Labels of the Node" + }, + "ready": { + "type": "string", + "title": "Node Readiness", + "description": "Node ready status", + "enum": [ + "True", + "False" + ], + "enumColors": { + "False": "red", + "True": "green" } - } + }, + "totalMemory": { + "type": "string", + "icon": "GPU", + "title": "Total Memory (kibibytes)", + "description": "Total memory capacity of the Node" + }, + "kubeletVersion": { + "type": "string", + "title": "Kubelet Version", + "description": "The node's kubelet version" + }, + "totalCPU": { + "type": "string", + "icon": "CPU", + "title": "Total CPU (milli-cores)", + "description": "Total CPU capacity of the Node" + } + }, + "required": [ + ] + }, + "mirrorProperties": { + }, + "calculationProperties": { + }, + "relations": { + "Cluster": { + "title": "Cluster", + "target": "cluster", + "required": false, + "many": true + } + } + }, + { + "identifier": "namespace", + "description": "This blueprint represents a k8s Namespace", + "title": "Namespace", + "icon": "Environment", + "schema": { + "properties": { + "creationTimestamp": { + "type": "string", + "title": "Created", + "format": "date-time", + "description": "When the Namespace was created" + }, + "labels": { + "type": "object", + "title": "Labels", + "description": "Labels of the Namespace" + } + }, + "required": [ + ] }, - { - "identifier": "workload", - "description": "This blueprint represents a k8s Workload. This includes all k8s objects which can create pods (deployments[replicasets], daemonsets, statefulsets...)", - "title": "Workload", - "icon": "Deployment", - "schema": { - "properties": { - "availableReplicas": { - "type": "number", - "title": "Running Replicas", - "description": "Current running replica count" - }, - "containers": { - "type": "array", - "title": "Containers", - "default": [], - "description": "The containers for each pod instance of the Workload" - }, - "creationTimestamp": { - "type": "string", - "title": "Created", - "format": "date-time", - "description": "When the Workload was created" - }, - "labels": { - "type": "object", - "title": "Labels", - "description": "Labels of the Workload" - }, - "replicas": { - "type": "number", - "title": "Wanted Replicas", - "description": "Wanted replica count" - }, - "strategy": { - "type": "string", - "title": "Strategy", - "description": "Rollout Strategy" - }, - "hasPrivileged": { - "type": "boolean", - "title": "Has Privileged Container" - }, - "hasLatest": { - "type": "boolean", - "title": "Has 'latest' tag", - "description": "Has Container with 'latest' as image tag" - }, - "hasLimits": { - "type": "boolean", - "title": "All containers have limits" - }, - "isHealthy": { - "type": "string", - "enum": [ - "Healthy", - "Unhealthy" - ], - "enumColors": { - "Healthy": "green", - "Unhealthy": "red" - }, - "title": "Workload Health" - }, - "kind": { - "title": "Workload Kind", - "description": "The kind of Workload", - "type": "string", - "enum": [ - "StatefulSet", - "DaemonSet", - "Deployment", - "ReplicaSet" - ] - }, - "strategyConfig": { - "type": "object", - "title": "Strategy Config", - "description": "The workloads rollout strategy" - } - }, - "required": [] - }, - "mirrorProperties": { - "Cluster": { - "title": "Cluster", - "path": "Namespace.Cluster.$title" - }, - "namespace": { - "title": "Namespace", - "path": "Namespace.$title" - } - }, - "calculationProperties": {}, - "relations": { - "workloadManager": { - "title": "Manager", - "description": "A replicaset's workload. For example, Workload abc-ReplicaSet is managed by Workload xyz-Depolyment", - "target": "workload", - "required": false, - "many": false - }, - "Namespace": { - "title": "Namespace", - "target": "namespace", - "required": false, - "many": false - } - } + "mirrorProperties": { }, - { - "identifier":"pod", - "description":"This blueprint represents a k8s Pod", - "title":"Pod", - "icon":"Service", - "schema":{ - "properties":{ - "conditions":{ - "type":"array", - "title":"Conditions", - "default":[ - - ], - "description":"Pod's conditions" - }, - "labels":{ - "type":"object", - "title":"Labels", - "description":"Labels of the Pod" - }, - "phase":{ - "type":"string", - "title":"Pod phase", - "description":"Pod's running phase" - }, - "startTime":{ - "type":"string", - "title":"Created", - "format":"date-time", - "description":"Pod's creation date" - } + "calculationProperties": { + }, + "relations": { + "Cluster": { + "title": "Cluster", + "description": "The namespace's Kubernetes cluster", + "target": "cluster", + "required": false, + "many": false + } + } + }, + { + "identifier": "workload", + "description": "This blueprint represents a k8s Workload. This includes all k8s objects which can create pods (deployments[replicasets], daemonsets, statefulsets...)", + "title": "Workload", + "icon": "Deployment", + "schema": { + "properties": { + "availableReplicas": { + "type": "number", + "title": "Running Replicas", + "description": "Current running replica count" + }, + "containers": { + "type": "array", + "title": "Containers", + "default": [], + "description": "The containers for each pod instance of the Workload" + }, + "creationTimestamp": { + "type": "string", + "title": "Created", + "format": "date-time", + "description": "When the Workload was created" + }, + "labels": { + "type": "object", + "title": "Labels", + "description": "Labels of the Workload" + }, + "replicas": { + "type": "number", + "title": "Wanted Replicas", + "description": "Wanted replica count" + }, + "strategy": { + "type": "string", + "title": "Strategy", + "description": "Rollout Strategy" + }, + "hasPrivileged": { + "type": "boolean", + "title": "Has Privileged Container" + }, + "hasLatest": { + "type": "boolean", + "title": "Has 'latest' tag", + "description": "Has Container with 'latest' as image tag" + }, + "hasLimits": { + "type": "boolean", + "title": "All containers have limits" + }, + "isHealthy": { + "type": "string", + "enum": [ + "Healthy", + "Unhealthy" + ], + "enumColors": { + "Healthy": "green", + "Unhealthy": "red" }, - "required":[ - + "title": "Workload Health" + }, + "kind": { + "title": "Workload Kind", + "description": "The kind of Workload", + "type": "string", + "enum": [ + "StatefulSet", + "DaemonSet", + "Deployment", + "ReplicaSet" ] - }, - "mirrorProperties":{ - "containers":{ - "title":"Containers", - "path":"workload.containers" - }, - "cluster":{ - "title":"Cluster", - "path":"workload.Namespace.Cluster.$identifier" - }, - "namespace":{ - "title":"Namespace", - "path":"workload.Namespace.$title" - } - }, - "calculationProperties":{ - - }, - "relations":{ - "Node":{ - "title":"Node", - "description":"The node the pod is running on", - "target":"node", - "required":false, - "many":false - }, - "workload":{ - "title":"Workload", - "description":"The workload responsible for the pod", - "target":"workload", - "required":false, - "many":false - } - } + }, + "strategyConfig": { + "type": "object", + "title": "Strategy Config", + "description": "The workloads rollout strategy" + } + }, + "required": [] }, - { - "identifier": "gateways", - "description": "This blueprint represents a service in our software catalog", - "title": "Istio Gateways", - "icon": "Cloud", - "schema": { - "properties": { - "name": { - "type": "string" - }, - "ports": { - "type": "array" - }, - "labels": { - "type": "object" - }, - "selector": { - "type": "object" - } - }, - "required": [] - }, - "mirrorProperties": {}, - "calculationProperties": {}, - "relations": { - "namespace": { - "target": "Namespace", - "required": true, - "many": false - } + "mirrorProperties": { + "Cluster": { + "title": "Cluster", + "path": "Namespace.Cluster.$title" + }, + "namespace": { + "title": "namespace", + "path": "Namespace.$title" + } + }, + "calculationProperties": {}, + "relations": { + "workloadManager": { + "title": "Manager", + "description": "A replicaset's workload. For example, Workload abc-ReplicaSet is managed by Workload xyz-Depolyment", + "target": "workload", + "required": false, + "many": false + }, + "Namespace": { + "title": "Namespace", + "target": "namespace", + "required": false, + "many": false + } + } + }, + { + "identifier": "pod", + "description": "This blueprint represents a k8s Pod", + "title": "Pod", + "icon": "Service", + "schema": { + "properties": { + "conditions": { + "type": "array", + "title": "Conditions", + "default": [ + ], + "description": "Pod's conditions" + }, + "labels": { + "type": "object", + "title": "Labels", + "description": "Labels of the Pod" + }, + "phase": { + "type": "string", + "title": "Pod phase", + "description": "Pod's running phase" + }, + "startTime": { + "type": "string", + "title": "Created", + "format": "date-time", + "description": "Pod's creation date" } }, - { - "identifier": "virtualServices", - "description": "This blueprint represents a service in our software catalog", - "title": "Virtual Services", - "icon": "Istio", - "schema": { - "properties": { - "hosts": { - "type": "array" - }, - "match": { - "type": "array" - }, - "labels": { - "type": "object" - } - }, - "required": [] - }, - "mirrorProperties": {}, - "calculationProperties": {}, - "relations": { - "gateways": { - "target": "gateways", - "required": true, - "many": true + "required": [ + ] + }, + "mirrorProperties": { + "containers": { + "title": "Containers", + "path": "workload.containers" + }, + "cluster": { + "title": "Cluster", + "path": "workload.Namespace.Cluster.$identifier" + }, + "namespace": { + "title": "Namespace", + "path": "workload.Namespace.$title" + } + }, + "calculationProperties": { + }, + "relations": { + "replicaSet": { + "title": "ReplicaSet", + "description": "The ReplicaSet managing the pod (if it exists)", + "target": "replicaSet", + "required": false, + "many": false + }, + "Node": { + "title": "Node", + "description": "The node the pod is running on", + "target": "node", + "required": false, + "many": false + }, + "workload": { + "title": "Workload", + "description": "The workload responsible for the pod", + "target": "workload", + "required": false, + "many": false + } + } + }, + { + "identifier": "replicaSet", + "description": "This blueprint represents a k8s ReplicaSet", + "title": "ReplicaSet", + "icon": "Deployment", + "schema": { + "properties": { + "replicaSetJson": { + "title": "ReplicaSet Json", + "type": "object", + "description": "The ReplicaSet json" + }, + "availableReplicas": { + "type": "number", + "title": "Running Replicas", + "description": "Current running replica count" + }, + "containers": { + "type": "array", + "title": "Containers", + "default": [], + "description": "The containers for each pod instance of the Workload" + }, + "creationTimestamp": { + "type": "string", + "title": "Created", + "format": "date-time", + "description": "When the Workload was created" + }, + "labels": { + "type": "object", + "title": "Labels", + "description": "Labels of the Workload" + }, + "replicas": { + "type": "number", + "title": "Wanted Replicas", + "description": "Wanted replica count" + }, + "strategy": { + "type": "string", + "title": "Strategy", + "description": "Rollout Strategy" + }, + "hasPrivileged": { + "type": "boolean", + "title": "Has Privileged Container" + }, + "hasLatest": { + "type": "boolean", + "title": "Has 'latest' tag", + "description": "Has Container with 'latest' as image tag" + }, + "hasLimits": { + "type": "boolean", + "title": "All containers have limits" + }, + "isHealthy": { + "type": "string", + "enum": [ + "Healthy", + "Unhealthy" + ], + "enumColors": { + "Healthy": "green", + "Unhealthy": "red" }, - "services": { - "target": "Service", - "required": false, - "many": true - } + "title": "ReplicaSet Health" + }, + "strategyConfig": { + "type": "object", + "title": "Strategy Config", + "description": "The ReplicaSet rollout strategy" + } + }, + "required": [] + }, + "mirrorProperties": {}, + "calculationProperties": {}, + "relations": { + "replicaSetManager": { + "title": "Manager", + "target": "workload", + "required": false, + "many": false + } + } + }, + { + "identifier": "gateways", + "description": "This blueprint represents a service in our software catalog", + "title": "Istio Gateways", + "icon": "Cloud", + "schema": { + "properties": { + "name": { + "type": "string" + }, + "ports": { + "type": "array" + }, + "labels": { + "type": "object" + }, + "selector": { + "type": "object" } + }, + "required": [] + }, + "mirrorProperties": {}, + "calculationProperties": {}, + "relations": { + "namespace": { + "target": "namespace", + "required": true, + "many": false + } + } + }, + { + "identifier": "virtualServices", + "description": "This blueprint represents a service in our software catalog", + "title": "Virtual Services", + "icon": "Istio", + "schema": { + "properties": { + "hosts": { + "type": "array" + }, + "match": { + "type": "array" + }, + "labels": { + "type": "object" + } + }, + "required": [] + }, + "mirrorProperties": {}, + "calculationProperties": {}, + "relations": { + "gateways": { + "target": "gateways", + "many": true } - ] \ No newline at end of file + } + } +] \ No newline at end of file diff --git a/kubernetes/install.sh b/kubernetes/install.sh index 2340afd..fbb6545 100644 --- a/kubernetes/install.sh +++ b/kubernetes/install.sh @@ -127,8 +127,10 @@ echo "" helm upgrade --install ${DEPLOYMENT_NAME} ${HELM_REPO_NAME}/${HELM_K8S_CHART_NAME} \ --create-namespace --namespace ${TARGET_NAMESPACE} \ --set secret.secrets.portClientId=${PORT_CLIENT_ID} --set secret.secrets.portClientSecret=${PORT_CLIENT_SECRET} \ - --set extraEnv[0]={"name": "CLUSTER_NAME", "value": "${CLUSTER_NAME}"} \ - --set extraEnv[1]={"name": "CREATE_DEFAULT_RESOURCES", "value": "false"} \ + --set createDefaultResources=false \ + --set-file configMap.config=${temp_dir}/template_config.yaml \ + --set extraEnv[0].name=CLUSTER_NAME \ + --set extraEnv[0].value=${CLUSTER_NAME} \ --set stateKey=${CLUSTER_NAME} echo "" From 1d908f748900a60ff589aa99b61b4aacfbe4c419 Mon Sep 17 00:00:00 2001 From: yair Date: Fri, 29 Dec 2023 17:36:24 +0200 Subject: [PATCH 4/5] updated script --- kubernetes/install.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kubernetes/install.sh b/kubernetes/install.sh index fbb6545..0080e99 100644 --- a/kubernetes/install.sh +++ b/kubernetes/install.sh @@ -73,10 +73,7 @@ echo "Beginning setup..." echo "" # Download config.yaml file into temporary folder -if [[ -z ${CONFIG_YAML_URL} ]]; then - echo "No custom config.yaml file configuration found. Please spciy a custom config.yaml file using the 'CONFIG_YAML_URL' variable." - exit 1 -else +if [[ -n ${CONFIG_YAML_URL} ]]; then echo "Custom config.yaml file configuration found." config_path_type=$(check_path_or_url ${CONFIG_YAML_URL}) # 'local' or 'url' if [[ "${config_path_type}" == 'local' ]]; then @@ -87,12 +84,14 @@ else echo "Failed to retrieve custom \`config.yaml\` ${CONFIG_YAML_URL}. Is the path/URL valid?" exit 1 fi +else + echo "" > "${temp_dir}/template_config.yaml" fi # Validate config.yaml is a valid yaml (cat ${temp_dir}/template_config.yaml | yq > /dev/null) || (echo "Failed to 'yq' parse the config.yaml. Is it a valid yaml? Exiting..." && exit 1) echo "" -if [[ ! -z ${CUSTOM_BP_PATH} ]]; then +if [[ -n ${CUSTOM_BP_PATH} ]]; then echo "Found custom a blueprints file configuration. Attempting to create blueprints defined in: ${CUSTOM_BP_PATH}" bp_path_type=$(check_path_or_url ${CUSTOM_BP_PATH}) # 'local' or 'url' if [[ "${bp_path_type}" == 'local' ]]; then From e1a44a893ecf88a22d8b91e5008f489bca94f7bd Mon Sep 17 00:00:00 2001 From: yair Date: Sun, 31 Dec 2023 15:21:33 +0200 Subject: [PATCH 5/5] reverts --- ...o_rollouts-istio-kubernetes_v1_config.yaml | 62 +++++++++---------- ...go-argo_rollouts-kubernetes_v1_config.yaml | 62 +++++++++---------- .../argo-istio-kubernetes_v1_config.yaml | 58 ++++++++--------- .../templates/argo-kubernetes_v1_config.yaml | 58 ++++++++--------- .../templates/istio-kubernetes_v1_config.yaml | 42 ++++++------- .../templates/kubernetes_v1_config.yaml | 42 ++++++------- 6 files changed, 162 insertions(+), 162 deletions(-) diff --git a/kubernetes/templates/argo-argo_rollouts-istio-kubernetes_v1_config.yaml b/kubernetes/templates/argo-argo_rollouts-istio-kubernetes_v1_config.yaml index b25a58f..1de9c1e 100644 --- a/kubernetes/templates/argo-argo_rollouts-istio-kubernetes_v1_config.yaml +++ b/kubernetes/templates/argo-argo_rollouts-istio-kubernetes_v1_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: env.CLUSTER_NAME + Cluster: '"{CLUSTER_NAME}"' - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: env.CLUSTER_NAME - title: env.CLUSTER_NAME + - identifier: '"{CLUSTER_NAME}"' + title: '"{CLUSTER_NAME}"' blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - title: .metadata.name + "-" + env.CLUSTER_NAME + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + title: .metadata.name + "-" + "{CLUSTER_NAME}" icon: '"Node"' blueprint: '"node"' properties: @@ -183,14 +183,14 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: env.CLUSTER_NAME + Cluster: '"{CLUSTER_NAME}"' # ArgoCD configuration - kind: argoproj.io/v1alpha1/applications port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" blueprint: '"argocdApp"' title: .metadata.name properties: @@ -201,20 +201,20 @@ resources: # List of K8s resources to list, watch, and export to Port. gitPath: .spec.source.path // null gitRev: .status.sync.revision // null relations: - workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-" + env.CLUSTER_NAME) // []' - argocdProject: .spec.project + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - destinationNamespace: .spec.destination.namespace + "-" + env.CLUSTER_NAME + workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-{CLUSTER_NAME}") // []' + argocdProject: .spec.project + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + destinationNamespace: .spec.destination.namespace + "-" + "{CLUSTER_NAME}" - kind: argoproj.io/v1alpha1/appproject port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"argocdProject"' properties: relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: v1/secrets selector: @@ -222,14 +222,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"argocdRepo"' properties: repoUrl: .data.url | @base64d repoType: .data.type | @base64d relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" # ArgoCD Rollouts configuration - kind: argoproj.io/v1alpha1/rollouts @@ -238,7 +238,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Rollout-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-Rollout-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -254,7 +254,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: networking.istio.io/v1beta1/virtualservices port: diff --git a/kubernetes/templates/argo-argo_rollouts-kubernetes_v1_config.yaml b/kubernetes/templates/argo-argo_rollouts-kubernetes_v1_config.yaml index 427b5ee..5609125 100644 --- a/kubernetes/templates/argo-argo_rollouts-kubernetes_v1_config.yaml +++ b/kubernetes/templates/argo-argo_rollouts-kubernetes_v1_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: 'env.CLUSTER_NAME' + Cluster: '"{CLUSTER_NAME}"' - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: env.CLUSTER_NAME - title: env.CLUSTER_NAME + - identifier: '"{CLUSTER_NAME}"' + title: '"{CLUSTER_NAME}"' blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - title: .metadata.name + "-" + env.CLUSTER_NAME + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + title: .metadata.name + "-" + "{CLUSTER_NAME}" icon: '"Node"' blueprint: '"node"' properties: @@ -183,14 +183,14 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: env.CLUSTER_NAME + Cluster: '"{CLUSTER_NAME}"' # ArgoCD configuration - kind: argoproj.io/v1alpha1/applications port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" blueprint: '"argocdApp"' title: .metadata.name properties: @@ -201,20 +201,20 @@ resources: # List of K8s resources to list, watch, and export to Port. gitPath: .spec.source.path // null gitRev: .status.sync.revision // null relations: - workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-" + env.CLUSTER_NAME) // []' - argocdProject: .spec.project + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - destinationNamespace: .spec.destination.namespace + "-" + env.CLUSTER_NAME + workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-{CLUSTER_NAME}") // []' + argocdProject: .spec.project + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + destinationNamespace: .spec.destination.namespace + "-" + "{CLUSTER_NAME}" - kind: argoproj.io/v1alpha1/appproject port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"argocdProject"' properties: relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: v1/secrets selector: @@ -222,14 +222,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"argocdRepo"' properties: repoUrl: .data.url | @base64d repoType: .data.type | @base64d relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" # ArgoCD Rollouts configuration - kind: argoproj.io/v1alpha1/rollouts @@ -238,7 +238,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Rollout-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-Rollout-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -254,4 +254,4 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" diff --git a/kubernetes/templates/argo-istio-kubernetes_v1_config.yaml b/kubernetes/templates/argo-istio-kubernetes_v1_config.yaml index 642eda3..535be85 100644 --- a/kubernetes/templates/argo-istio-kubernetes_v1_config.yaml +++ b/kubernetes/templates/argo-istio-kubernetes_v1_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: env.CLUSTER_NAME + Cluster: '"{CLUSTER_NAME}"' - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: env.CLUSTER_NAME - title: env.CLUSTER_NAME + - identifier: '"{CLUSTER_NAME}"' + title: '"{CLUSTER_NAME}"' blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - title: .metadata.name + "-" + env.CLUSTER_NAME + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + title: .metadata.name + "-" + "{CLUSTER_NAME}" icon: '"Node"' blueprint: '"node"' properties: @@ -183,14 +183,14 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: env.CLUSTER_NAME + Cluster: '"{CLUSTER_NAME}"' # ArgoCD configuration - kind: argoproj.io/v1alpha1/applications port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" blueprint: '"argocdApp"' title: .metadata.name properties: @@ -201,20 +201,20 @@ resources: # List of K8s resources to list, watch, and export to Port. gitPath: .spec.source.path // null gitRev: .status.sync.revision // null relations: - workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-" + env.CLUSTER_NAME) // []' - argocdProject: .spec.project + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - destinationNamespace: .spec.destination.namespace + "-" + env.CLUSTER_NAME + workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-{CLUSTER_NAME}") // []' + argocdProject: .spec.project + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + destinationNamespace: .spec.destination.namespace + "-" + "{CLUSTER_NAME}" - kind: argoproj.io/v1alpha1/appproject port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"argocdProject"' properties: relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: v1/secrets selector: @@ -222,14 +222,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"argocdRepo"' properties: repoUrl: .data.url | @base64d repoType: .data.type | @base64d relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: networking.istio.io/v1beta1/virtualservices port: diff --git a/kubernetes/templates/argo-kubernetes_v1_config.yaml b/kubernetes/templates/argo-kubernetes_v1_config.yaml index 2a7a4b3..979053e 100644 --- a/kubernetes/templates/argo-kubernetes_v1_config.yaml +++ b/kubernetes/templates/argo-kubernetes_v1_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: env.CLUSTER_NAME + Cluster: '"{CLUSTER_NAME}"' - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: env.CLUSTER_NAME - title: 'env.CLUSTER_NAME' + - identifier: '"{CLUSTER_NAME}"' + title: '"{CLUSTER_NAME}"' blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - title: .metadata.name + "-" + env.CLUSTER_NAME + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + title: .metadata.name + "-" + "{CLUSTER_NAME}" icon: '"Node"' blueprint: '"node"' properties: @@ -183,14 +183,14 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: env.CLUSTER_NAME + Cluster: '"{CLUSTER_NAME}"' # ArgoCD configuration - kind: argoproj.io/v1alpha1/applications port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" blueprint: '"argocdApp"' title: .metadata.name properties: @@ -201,20 +201,20 @@ resources: # List of K8s resources to list, watch, and export to Port. gitPath: .spec.source.path // null gitRev: .status.sync.revision // null relations: - workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-" + env.CLUSTER_NAME) // []' - argocdProject: .spec.project + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - destinationNamespace: .spec.destination.namespace + "-" + env.CLUSTER_NAME + workload: '(.spec.destination.namespace as $namespace | .status.resources | map(select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet" or .kind == "Rollout" )) | .[] | .name + "-" + .kind + "-" + $namespace + "-{CLUSTER_NAME}") // []' + argocdProject: .spec.project + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + destinationNamespace: .spec.destination.namespace + "-" + "{CLUSTER_NAME}" - kind: argoproj.io/v1alpha1/appproject port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"argocdProject"' properties: relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: v1/secrets selector: @@ -222,11 +222,11 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"argocdRepo"' properties: repoUrl: .data.url | @base64d repoType: .data.type | @base64d relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" diff --git a/kubernetes/templates/istio-kubernetes_v1_config.yaml b/kubernetes/templates/istio-kubernetes_v1_config.yaml index 248a670..fa6c433 100644 --- a/kubernetes/templates/istio-kubernetes_v1_config.yaml +++ b/kubernetes/templates/istio-kubernetes_v1_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: 'env.CLUSTER_NAME' + Cluster: '"{CLUSTER_NAME}"' - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: env.CLUSTER_NAME - title: env.CLUSTER_NAME + - identifier: '"{CLUSTER_NAME}"' + title: '"{CLUSTER_NAME}"' blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - title: .metadata.name + "-" + env.CLUSTER_NAME + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + title: .metadata.name + "-" + "{CLUSTER_NAME}" icon: '"Node"' blueprint: '"node"' properties: @@ -183,7 +183,7 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: 'env.CLUSTER_NAME' + Cluster: '"{CLUSTER_NAME}"' - kind: networking.istio.io/v1beta1/virtualservices port: diff --git a/kubernetes/templates/kubernetes_v1_config.yaml b/kubernetes/templates/kubernetes_v1_config.yaml index 8c822bf..66bb30c 100644 --- a/kubernetes/templates/kubernetes_v1_config.yaml +++ b/kubernetes/templates/kubernetes_v1_config.yaml @@ -7,14 +7,14 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: # Mappings between one K8s object to one or many Port Entities. Each value is a JQ query. - - identifier: .metadata.name + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"namespace"' properties: creationTimestamp: .metadata.creationTimestamp labels: .metadata.labels relations: - Cluster: env.CLUSTER_NAME + Cluster: '"{CLUSTER_NAME}"' - kind: v1/namespaces selector: @@ -22,8 +22,8 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: env.CLUSTER_NAME - title: env.CLUSTER_NAME + - identifier: '"{CLUSTER_NAME}"' + title: '"{CLUSTER_NAME}"' blueprint: '"cluster"' - kind: apps/v1/deployments @@ -32,7 +32,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-Deployment-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Deployment"' blueprint: '"workload"' @@ -50,7 +50,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/daemonsets selector: @@ -58,7 +58,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-DaemonSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -74,7 +74,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/statefulsets selector: @@ -82,7 +82,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-StatefulSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name blueprint: '"workload"' properties: @@ -98,7 +98,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - Namespace: .metadata.namespace + "-" + env.CLUSTER_NAME + Namespace: .metadata.namespace + "-" + "{CLUSTER_NAME}" - kind: apps/v1/replicasets selector: @@ -106,7 +106,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-ReplicaSet-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Deployment"' blueprint: '"replicaSet"' @@ -122,7 +122,7 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.template.spec.containers | map({name, image, resources})) isHealthy: if .spec.replicas == .status.availableReplicas then "Healthy" else "Unhealthy" end relations: - replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME // [] + replicaSetManager: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" // [] # Pods who are owned by replica-sets are connected directly to their deployment - kind: v1/pods @@ -131,7 +131,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -142,8 +142,8 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME // "" + replicaSet: .metadata.ownerReferences[0].name + "-" + "ReplicaSet" + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" // "" # Pods that are not managed by replicasets->deployments (daemonsets, statefulsets etc) @@ -153,7 +153,7 @@ resources: # List of K8s resources to list, watch, and export to Port. port: entity: mappings: - - identifier: .metadata.name + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME + - identifier: .metadata.name + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" title: .metadata.name icon: '"Microservices"' blueprint: '"pod"' @@ -164,15 +164,15 @@ resources: # List of K8s resources to list, watch, and export to Port. containers: (.spec.containers | map({image, resources})) + .status.containerStatuses | group_by(.image) | map(add) conditions: .status.conditions relations: - workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + env.CLUSTER_NAME - Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME + workload: .metadata.ownerReferences[0].name + "-" + .metadata.ownerReferences[0].kind + "-" + .metadata.namespace + "-" + "{CLUSTER_NAME}" + Node: (.spec.nodeName) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" - kind: v1/nodes port: entity: mappings: - - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + env.CLUSTER_NAME - title: .metadata.name + "-" + env.CLUSTER_NAME + - identifier: (.metadata.name) | (split(".")|join("_")) + "-" + "{CLUSTER_NAME}" + title: .metadata.name + "-" + "{CLUSTER_NAME}" icon: '"Node"' blueprint: '"node"' properties: @@ -183,4 +183,4 @@ resources: # List of K8s resources to list, watch, and export to Port. kubeletVersion: .status.nodeInfo.kubeletVersion | split("-") | .[0] ready: .status.conditions[] | select(.type == "Ready") | .status relations: - Cluster: env.CLUSTER_NAME + Cluster: '"{CLUSTER_NAME}"'