Skip to content

Commit 1428b5e

Browse files
authored
Merge branch 'skupperproject:main' into 2063
2 parents efb35d0 + 378a0e5 commit 1428b5e

10 files changed

Lines changed: 141 additions & 99 deletions

File tree

charts/README.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,9 @@
22

33
### Skupper chart
44

5-
The skupper chart is generated from common config files, so you will need to run:
6-
```asciidoc
7-
make generate-skupper-helm-chart
8-
```
9-
10-
This action will create a `skupper` chart inside the `charts` directory, that
11-
you can install with a clustered scope with:
12-
```
13-
helm install skupper ./skupper --set scope=cluster
14-
```
15-
Other option is to install it in a namespaced scope:
16-
```
17-
helm install skupper ./skupper --set scope=namespace
18-
```
19-
20-
Check the `values.yaml` to modify the image tag of the controller, kube-adaptor and router images.
21-
5+
[Instructions on how to deploy the Skupper chart](skupper/README.md)
226

237
### Network-observer chart
248

25-
[Instructions on how to deploy the network-observer chart.](https://github.com/skupperproject/skupper/blob/main/charts/network-observer/README.md)
9+
[Instructions on how to deploy the network-observer chart](network-observer/README.md)
2610

charts/skupper/README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,24 @@ routerImage: examplemirror.acme.com/skupper/skupper-router:3.3.0
5252

5353
## Alternative Installation Methods
5454

55-
In addition to this Helm Chart, Skupper releases static manifest yamls for
55+
In addition to this Helm Chart, Skupper releases static manifest [YAML](../../cmd/controller/README.md) for
5656
deploying both cluster and namespace-scoped controllers.
5757

58-
```
59-
SKUPPER_VERSION=2.0.0
60-
# Deploys a cluster scoped controller to the 'skupper' namespace.
61-
kubectl apply -f "https://github.com/skupperproject/skupper/releases/download/$SKUPPER_VERSION/skupper-cluster-scope.yaml"
62-
# Deploys a namespace scoped controller to the current context namespace.
63-
kubectl apply -f "https://github.com/skupperproject/skupper/releases/download/$SKUPPER_VERSION/skupper-namespace-scope.yaml"
58+
## Development
59+
60+
The skupper chart is generated from common config files, so you will need to run:
61+
```asciidoc
62+
make generate-skupper-helm-chart
6463
```
6564

66-
## Development
65+
This action will create a `skupper` chart inside the `charts` directory, that
66+
you can install with a clustered scope with:
67+
```
68+
helm install skupper ./skupper --set scope=cluster
69+
```
70+
Other option is to install it in a namespaced scope:
71+
```
72+
helm install skupper ./skupper --set scope=namespace
73+
```
6774

68-
This Helm Chart is generated. For instructions on working with this chart see
69-
[skupper/charts](https://github.com/skupperproject/skupper/tree/main/charts).
75+
Check the `values.yaml` to modify the image tag of the controller, kube-adaptor and router images.

cmd/controller/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Skupper controller
2+
3+
Skupper releases static manifest yamls for deploying both cluster and namespace-scoped controllers.
4+
5+
```
6+
SKUPPER_VERSION=v2-dev-release
7+
# Deploys a cluster scoped controller to the 'skupper' namespace.
8+
kubectl apply -f "https://github.com/skupperproject/skupper/releases/download/$SKUPPER_VERSION/skupper-cluster-scope.yaml"
9+
# Deploys a namespace scoped controller to the current context namespace.
10+
kubectl apply -f "https://github.com/skupperproject/skupper/releases/download/$SKUPPER_VERSION/skupper-namespace-scope.yaml"
11+
```
12+
13+
Alternatively, clone this repo and generate the YAML files using:
14+
15+
```
16+
make generate-skupper-deployment-cluster-scoped
17+
make generate-skupper-deployment-namespace-scoped
18+
```
19+
20+
You can also install using [Helm charts](../../charts/README.md).

cmd/controller/example/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ This example demonstrates how to connect two sites declaratively, without relyin
44

55
## Installing the skupper controller
66

7-
The controller can be installed using the Helm chart, with detailed instructions provided
8-
[here](https://github.com/skupperproject/skupper/blob/main/charts/README.md)
7+
The controller can be installed using:
8+
9+
* [YAML](../README.md)
10+
* [Helm chart](../../../charts/README.md)
911

1012
## Deploy application in two namespaces (or contexts)
1113

internal/kube/controller/controller_test.go

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"flag"
77
"fmt"
88
"reflect"
9+
"strings"
910
"testing"
1011

1112
"github.com/google/uuid"
@@ -619,6 +620,26 @@ func TestUpdate(t *testing.T) {
619620
serviceCheck("adifferentsvc", "test").check,
620621
negativeServiceCheck("mysvc", "test"),
621622
},
623+
}, {
624+
name: "exposePodsByName handles pod delete",
625+
k8sObjects: []runtime.Object{
626+
f.skupperNetworkStatus("test", f.networkStatusInfo("mysite", "test", map[string]string{"mysvc": "mysvc", "mysvc.mypod-1": "mysvc@mypod-1", "mysvc.mypod-2": "mysvc@mypod-2"}, map[string]string{"mysvc": "mysvc", "mysvc.mypod-1": "10.1.1.10", "mysvc.mypod-2": "10.1.1.11"}).info()),
627+
f.pod("mypod-1", "test", map[string]string{"app": "foo"}, nil, f.podStatus("10.1.1.10", corev1.PodRunning, f.podCondition(corev1.PodReady, corev1.ConditionTrue))),
628+
f.pod("mypod-2", "test", map[string]string{"app": "foo"}, nil, f.podStatus("10.1.1.11", corev1.PodRunning, f.podCondition(corev1.PodReady, corev1.ConditionTrue))),
629+
},
630+
skupperObjects: []runtime.Object{
631+
f.site("mysite", "test", "", false, false),
632+
f.connectorWithExposePodsByName("myconnector", "test", "mysvc", "app=foo", 8080),
633+
f.listenerWithExposePodsByName("mylistener", "test", "mysvc", "mysvc", 8080),
634+
},
635+
functions: []WaitFunction{
636+
isConnectorStatusConditionTrue("myconnector", "test", skupperv2alpha1.CONDITION_TYPE_CONFIGURED),
637+
isListenerStatusConditionTrue("mylistener", "test", skupperv2alpha1.CONDITION_TYPE_CONFIGURED),
638+
serviceCheck("mysvc", "test").check,
639+
serviceCheck("mypod-1", "test").check,
640+
deleteTargetPod("mypod-1", "test"),
641+
serviceCheck("mypod-1", "test").checkAbsent,
642+
},
622643
},
623644
}
624645
for _, tt := range testTable {
@@ -641,6 +662,7 @@ func TestUpdate(t *testing.T) {
641662
for i := 0; i < len(tt.k8sObjects)+len(tt.skupperObjects); i++ {
642663
controller.controller.TestProcess()
643664
}
665+
644666
for _, f := range tt.functions {
645667
for !f(t, clients) {
646668
controller.controller.TestProcess()
@@ -1645,26 +1667,6 @@ func serviceCheck(name string, namespace string) *ServiceCheck {
16451667
}
16461668
}
16471669

1648-
func (s *ServiceCheck) selector(selector map[string]string) *ServiceCheck {
1649-
s.selector_ = selector
1650-
return s
1651-
}
1652-
1653-
func (s *ServiceCheck) ports(ports ...corev1.ServicePort) *ServiceCheck {
1654-
s.ports_ = ports
1655-
return s
1656-
}
1657-
1658-
func (s *ServiceCheck) labels(labels map[string]string) *ServiceCheck {
1659-
s.labels_ = labels
1660-
return s
1661-
}
1662-
1663-
func (s *ServiceCheck) annotations(annotations map[string]string) *ServiceCheck {
1664-
s.annotations_ = annotations
1665-
return s
1666-
}
1667-
16681670
func (s *ServiceCheck) check(t *testing.T, clients internalclient.Clients) bool {
16691671
actual, err := clients.GetKubeClient().CoreV1().Services(s.namespace).Get(context.Background(), s.name, metav1.GetOptions{})
16701672
assert.Assert(t, err)
@@ -1692,6 +1694,18 @@ func (s *ServiceCheck) check(t *testing.T, clients internalclient.Clients) bool
16921694
return true
16931695
}
16941696

1697+
func (s *ServiceCheck) checkAbsent(t *testing.T, clients internalclient.Clients) bool {
1698+
_, err := clients.GetKubeClient().CoreV1().Services(s.namespace).Get(context.Background(), s.name, metav1.GetOptions{})
1699+
if err == nil {
1700+
return false
1701+
}
1702+
if errors.IsNotFound(err) {
1703+
return true
1704+
}
1705+
assert.Assert(t, err)
1706+
return false
1707+
}
1708+
16951709
func updateListener(name string, namespace string, host string, port int) WaitFunction {
16961710
return func(t *testing.T, clients internalclient.Clients) bool {
16971711
ctxt := context.Background()
@@ -1713,3 +1727,34 @@ func negativeServiceCheck(name string, namespace string) WaitFunction {
17131727
return true
17141728
}
17151729
}
1730+
1731+
func deleteTargetPod(name string, namespace string) WaitFunction {
1732+
return func(t *testing.T, clients internalclient.Clients) bool {
1733+
ctxt := context.Background()
1734+
err := clients.GetKubeClient().CoreV1().Pods(namespace).Delete(ctxt, name, metav1.DeleteOptions{})
1735+
assert.Assert(t, err)
1736+
cm, err := clients.GetKubeClient().CoreV1().ConfigMaps(namespace).Get(ctxt, "skupper-network-status", metav1.GetOptions{})
1737+
assert.Assert(t, err)
1738+
cm = cm.DeepCopy()
1739+
var status network.NetworkStatusInfo
1740+
assert.Assert(t, json.Unmarshal([]byte(cm.Data["NetworkStatus"]), &status))
1741+
suffix := "." + name
1742+
for sIdx := range status.SiteStatus {
1743+
for rIdx, rs := range status.SiteStatus[sIdx].RouterStatus {
1744+
connectors := rs.Connectors[:0]
1745+
for _, c := range rs.Connectors {
1746+
if !strings.HasSuffix(c.Address, suffix) {
1747+
connectors = append(connectors, c)
1748+
}
1749+
}
1750+
status.SiteStatus[sIdx].RouterStatus[rIdx].Connectors = connectors
1751+
}
1752+
}
1753+
sb, err := json.Marshal(status)
1754+
assert.Assert(t, err)
1755+
cm.Data["NetworkStatus"] = string(sb)
1756+
_, err = clients.GetKubeClient().CoreV1().ConfigMaps(namespace).Update(ctxt, cm, metav1.UpdateOptions{})
1757+
assert.Assert(t, err)
1758+
return true
1759+
}
1760+
}

internal/kube/site/per_target_listener.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func extractTargets(prefix string, network []skupperv2alpha1.SiteRecord) []strin
143143
var results []string
144144
for _, site := range network {
145145
for _, service := range site.Services {
146-
if strings.HasPrefix(service.RoutingKey, prefix) {
146+
if strings.HasPrefix(service.RoutingKey, prefix) && len(service.Connectors) > 0 {
147147
results = append(results, strings.TrimPrefix(service.RoutingKey, prefix))
148148
}
149149
}

internal/nonkube/bundle/install.sh.template

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,16 @@ sanity_check() {
306306
exit 1
307307
fi
308308
fi
309+
310+
if [ ! -d "${NAMESPACES_PATH:?}/${NAMESPACE:?}/runtime" ]; then
311+
if [ "${SKUPPER_PLATFORM}" != "linux" ]; then
312+
router_container="${NAMESPACE}-skupper-router"
313+
if ${PLATFORM_COMMAND} container inspect "${router_container}" > /dev/null 2>&1; then
314+
echo "Failed: container ${router_container} already exists"
315+
exit 1
316+
fi
317+
fi
318+
fi
309319
}
310320

311321
list_valid_certificates() {

internal/nonkube/compat/site_state_renderer.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ func (s *SiteStateRenderer) Render(loadedSiteState *api.SiteState, reload bool)
114114
}
115115
// active (runtime) SiteState
116116
s.siteState = common.CopySiteState(s.loadedSiteState)
117+
if err = s.preventContainersConflict(); err != nil {
118+
return err
119+
}
117120
err = common.RedeemClaims(s.siteState)
118121
if err != nil {
119122
return fmt.Errorf("failed to redeem claims: %v", err)
@@ -200,11 +203,15 @@ func (s *SiteStateRenderer) cleanupExistingNamespace(siteState *api.SiteState) e
200203
return common.CleanupNamespaceForReload(siteState.GetNamespace())
201204
}
202205

206+
func (s *SiteStateRenderer) routerContainerName() string {
207+
return fmt.Sprintf("%s-skupper-router", s.siteState.GetNamespace())
208+
}
209+
203210
func (s *SiteStateRenderer) prepareContainers() error {
204211
siteConfigPath := api.GetHostSiteHome(s.siteState.Site)
205212
s.containers = make(map[string]container.Container)
206213
s.containers[types.RouterComponent] = container.Container{
207-
Name: fmt.Sprintf("%s-skupper-router", s.siteState.GetNamespace()),
214+
Name: s.routerContainerName(),
208215
Image: images.GetRouterImageName(),
209216
Env: map[string]string{
210217
"APPLICATION_NAME": "skupper-router",
@@ -354,3 +361,16 @@ func (s *SiteStateRenderer) createSystemdService() error {
354361

355362
return nil
356363
}
364+
365+
func (s *SiteStateRenderer) preventContainersConflict() error {
366+
runtimeStatePath := api.GetInternalOutputPath(s.loadedSiteState.GetNamespace(), api.RuntimeSiteStatePath)
367+
_, err := os.Stat(runtimeStatePath)
368+
// no runtime state and container exists
369+
if err != nil && os.IsNotExist(err) {
370+
containerName := s.routerContainerName()
371+
if _, err = s.cli.ContainerInspect(containerName); err == nil {
372+
return fmt.Errorf("container %q already exists", containerName)
373+
}
374+
}
375+
return nil
376+
}

internal/qdr/skmanage.go

Lines changed: 0 additions & 45 deletions
This file was deleted.

tests/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ROOT_PATH := $(shell pwd)
22
EXTRA_VARS := --extra-vars "@$(ROOT_PATH)/vars.yml"
33
COLLECTION_PATH := $(ROOT_PATH)/e2e/collections/ansible_collections/e2e/tests
4-
TESTS_CI := attached-connector
4+
TESTS_CI := attached-connector,ha
55

66
# E2E Test directories
77
E2E_TEST_DIRS := $(sort $(wildcard $(ROOT_PATH)/e2e/scenarios/*))
@@ -102,4 +102,4 @@ test-subset: create-venv
102102

103103
# Run a subset of tests (comma-separated list) for CI
104104
ci-tests: TESTS=$(TESTS_CI)
105-
ci-tests: test-subset
105+
ci-tests: test-subset

0 commit comments

Comments
 (0)