Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: k8s config for reaching out kardinal kontrol running in localhost #1

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading