Skip to content

Commit

Permalink
get pods instead of getting service for internal registry tunnel
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
  • Loading branch information
AustinAbro321 committed Sep 4, 2024
1 parent 0a3c2ff commit 5b16e94
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/pkg/cluster/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package cluster

import (
"context"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -147,8 +148,23 @@ func (c *Cluster) ConnectToZarfRegistryEndpoint(ctx context.Context, registryInf
var err error
var tunnel *Tunnel
if registryInfo.IsInternal() {
registrySvc, err := c.Clientset.CoreV1().Services(ZarfNamespaceName).Get(ctx, ZarfRegistryName, metav1.GetOptions{})
if err != nil {
return "", nil, err
}
selector, err := metav1.LabelSelectorAsSelector(&metav1.LabelSelector{MatchLabels: registrySvc.Spec.Selector})
if err != nil {
return "", nil, err
}
podList, err := c.Clientset.CoreV1().Pods(ZarfNamespaceName).List(ctx, metav1.ListOptions{LabelSelector: selector.String()})
if err != nil {
return "", nil, err
}
if len(podList.Items) < 1 {
return "", nil, errors.New("no pods for internal registry")
}
// Establish a registry tunnel to send the images to the zarf registry
if tunnel, err = c.NewTunnel(ZarfNamespaceName, SvcResource, ZarfRegistryName, "", 0, ZarfRegistryPort); err != nil {
if tunnel, err = c.NewTunnel(ZarfNamespaceName, PodResource, podList.Items[0].Name, "", 0, ZarfRegistryPort); err != nil {
return "", tunnel, err
}
} else {
Expand Down

0 comments on commit 5b16e94

Please sign in to comment.