Skip to main content

Check out Port for yourself ➜ 

Advanced

The K8s exporter supports additional flags and the option to provide additional configuration sources, making it easier to configure its behavior to your liking.

Required configuration

The following parameters are required with every K8s exporter installation/upgrade:

ParameterDescription
secret.secrets.portClientIdPort Client ID
secret.secrets.portClientSecretPort Client Secret

Advanced installation parameters

The following advanced configuration parameters are available:

The resyncInterval parameter specifies the interval in minutes to send a repeated sync event for all known existing objects (in addition to new cluster events).

  • Default value: 0 (re-sync disabled)
  • Use case: Re-sync every X minutes. This parameter is useful when reporting entities with relations inside your cluster in instances where an entity is reported before its related target has been created in Port. The initial sync will fail, but later when the target entity is available, the entity creation will succeed.

Security Configuration

The following security parameters can be modified to give the K8s exporter more granular access to your cluster:

ParameterDescriptionDefault
clusterRole.apiGroupsThe API groups that the K8s Exporter can access. Make sure to grant access to the relevant API groups, with respect to the resources that you've configured in the resource mapping{'*'}
clusterRole.resourcesThe resources that the K8s Exporter can access. Make sure to grant access to the relevant resources, with respect to the resources that you've configured in the resource mapping{'*'}
serviceAccount.createWhether to create the default ServiceAccount, ClusterRole and ClusterRoleBinding resources.true
serviceAccount.nameThe name of the custom ServiceAccount resource to use, relevant only when serviceAccount.create is set to false

Overriding configurations

When installing the K8s exporter, it is possible to override default values in the helm upgrade command:

By using the --set flag, you can override specific exporter configuration parameters during exporter installation/upgrade:

helm upgrade --install k8s-exporter port-labs/port-k8s-exporter \
--create-namespace --namespace port-k8s-exporter \
--set secret.secrets.portClientId="YOUR_PORT_CLIENT_ID" \
--set secret.secrets.portClientSecret="YOUR_PORT_CLIENT_SECRET" \
--set stateKey="k8s-exporter" \
--set eventListenerType="KAFKA" \
--set extraEnv=[{"name":"CLUSTER_NAME","value":"my-cluster"}]

For example, to set the parameters from the security configuration section:

--set clusterRole.apiGroups="{argoproj.io,'',apps}" \
--set clusterRole.resources="{rollouts,pods,replicasets}"

Manage K8s mapping config

The K8s exporter's mapping configuration (the resources block, crdsToDiscover, etc.) can be managed in two ways: through the Port UI or through your Helm chart values. The overwriteConfigurationOnRestart parameter controls which approach is used.

Port UI (default)

By default (overwriteConfigurationOnRestart: false), the mapping defined in your Helm values is synced to Port only during the initial installation. After that:

  • The data sources page in Port is the source of truth.
  • You can edit the mapping in the Port UI and click Save & Resync to apply changes.
  • Any mapping changes in your Helm values will be ignored on subsequent upgrades or restarts.

This is the recommended approach if you prefer to iterate on your mapping through the Port UI.

Helm chart / GitOps

If you want to manage your mapping declaratively (e.g. storing it in Git alongside your Helm values), set overwriteConfigurationOnRestart: true. With this approach:

  • The Helm chart is the source of truth for the mapping configuration.
  • On every exporter restart, the local configuration is pushed to Port, overwriting any changes made in the UI.
  • All mapping changes should be made in your Helm values file and applied via helm upgrade.

To use this approach, provide your mapping configuration via the configMap.config value:

Example values.yaml (Click to expand)
values.yaml
overwriteConfigurationOnRestart: true

configMap:
config: |
crdsToDiscover: ".metadata.ownerReferences[0].kind == \"CompositeResourceDefinition\""
resources:
- kind: apps/v1/deployments
selector:
query: .metadata.namespace | startswith("kube") | not
port:
entity:
mappings:
- identifier: .metadata.name + "-Deployment-" + .metadata.namespace
title: .metadata.name
blueprint: '"k8s_workload"'
properties:
kind: '"Deployment"'
creationTimestamp: .metadata.creationTimestamp
Switching between approaches

If you have been managing your mapping in the Port UI and want to switch to a GitOps approach, first copy the current mapping from the data sources page into your Helm values file. Then set overwriteConfigurationOnRestart: true and run helm upgrade. This ensures you don't lose any mapping changes you previously made in the UI.

All configuration parameters

  • A complete list of configuration parameters available when using the helm chart is available here.
  • An example skeleton values.yml file is available here.

Extra environment variables

To pass extra environment variables to the exporter's runtime, you can use the Helm chart provided with the installation. You can do this in one of two ways:

  1. Using Helm's --set flag:
helm upgrade --install <MY_INSTALLATION_NAME> port-labs/port-k8s-exporter \
# Standard installation flags
# ...
--set "extraEnv[0].name"=HTTP_PROXY \
--set "extraEnv[0].value"=http://my-proxy.com:1111
  1. The Helm values.yaml file:
# The rest of the configuration
# ...
extraEnvs:
- name: HTTP_PROXY
value: http://my-proxy.com:1111

Proxy Configuration

HTTP_PROXY & HTTPS_PROXY

HTTP_PROXY and HTTPS_PROXY are environment variables used to specify a proxy server for handling HTTP or HTTPS, respectively. The values assigned to these settings should be the URL of the proxy server.

For example:

HTTP_PROXY=http://my-proxy.com:1111
HTTPS_PROXY=http://my-proxy.com:2222

NO_PROXY

NO_PROXY allows blacklisting certain addresses from being handled through a proxy. This variable accepts a comma-seperated list of hostnames or urls.

For example:

NO_PROXY=http://127.0.0.1,google.com

Advanced resource mapping configuration

The deleteDependents parameter is used to enable deletion of dependent Port entities. This is useful when you have two blueprints with a required relation, and the target entity in the relation should be deleted. In this scenario, the delete operation will fail if this flag is set to false if the flag is set to true, the source entity will be deleted as well.

  • Default value: false (disabled)
  • Use case: Deletion of dependent Port entities. Must be enabled if you want to delete a target entity (and its source entities) when the entity's blueprint has required relations.