Skip to content

Commit

Permalink
k8s config for reaching out kardinal kontrol running in localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
leoporoli committed Jun 27, 2024
1 parent 80e4be1 commit 1563507
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion kardinal-manager/deployment/k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ metadata:
name: kardinal-manager-role
rules:
- apiGroups: ["*"]
resources: ["pods", "services", "deployments", "virtualservices", "workloadgroups", "workloadentries", "sidecars", "serviceentries", "gateways", "envoyfilters", "destinationrules"]
resources: ["namespaces", "pods", "services", "deployments", "virtualservices", "workloadgroups", "workloadentries", "sidecars", "serviceentries", "gateways", "envoyfilters", "destinationrules"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]

---
Expand Down Expand Up @@ -55,3 +55,8 @@ spec:
value: "kubernetes.default.svc"
- name: KUBERNETES_SERVICE_PORT
value: "443"
- name: CLUSTER_CONFIG_ENDPOINT
# This is valid for reaching out the Kardinal Kontrol if this is running on the host
value: "http://host.minikube.internal:8080/cluster-resources"
- name: FETCHER_JOB_DURATION_SECONDS
value: "10"
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/kurtosis-tech/kardinal/libs/manager-kontrol-api/api/golang/types"
"github.com/kurtosis-tech/stacktrace"
"github.com/samber/lo"
"github.com/sirupsen/logrus"
istio "istio.io/api/networking/v1alpha3"
"istio.io/client-go/pkg/apis/networking/v1alpha3"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -181,6 +182,11 @@ func (manager *ClusterManager) GetTopologyForNameSpace(namespace string) (map[st

func (manager *ClusterManager) ApplyClusterResources(ctx context.Context, clusterResources *types.ClusterResources) error {

if clusterResources == nil {
logrus.Debugf("the received cluster resources is nil, nothing to apply.")
return nil
}

allNSs := [][]string{
lo.Uniq(lo.Map(*clusterResources.Services, func(item corev1.Service, _ int) string { return item.Namespace })),
lo.Uniq(lo.Map(*clusterResources.Deployments, func(item appsv1.Deployment, _ int) string { return item.Namespace })),
Expand All @@ -191,11 +197,9 @@ func (manager *ClusterManager) ApplyClusterResources(ctx context.Context, cluste

uniqueNamespaces := lo.Uniq(lo.Flatten(allNSs))

var ensureNamespacesErr error

for _, namespace := range uniqueNamespaces {
if err := manager.ensureNamespace(ctx, namespace); err != nil {
return stacktrace.Propagate(ensureNamespacesErr, "An error occurred while creating or updating cluster namespace '%s'", namespace)
return stacktrace.Propagate(err, "An error occurred while creating or updating cluster namespace '%s'", namespace)
}
}

Expand Down

0 comments on commit 1563507

Please sign in to comment.