Skip to content

Commit

Permalink
Merge pull request #1 from kurtosis-tech/lporoli/update-k8s-deployment
Browse files Browse the repository at this point in the history
feat: k8s config for reaching out kardinal kontrol running in localhost
  • Loading branch information
lostbean authored Jun 27, 2024
2 parents d2febe7 + 1563507 commit fbd8035
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 fbd8035

Please sign in to comment.