Skip to content

Commit bb6dbf0

Browse files
authored
Merge pull request #107 from mjudeikis/mjudeikis/base.url.override
Allow override shard base url
2 parents 52e494a + 82ea30a commit bb6dbf0

File tree

11 files changed

+145
-0
lines changed

11 files changed

+145
-0
lines changed

config/crd/bases/operator.kcp.io_rootshards.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,8 @@ spec:
485485
type: object
486486
type: object
487487
clusterDomain:
488+
description: ClusterDomain is the DNS domain for services in the cluster.
489+
Defaults to "cluster.local" if not set.
488490
type: string
489491
deploymentTemplate:
490492
description: 'Optional: DeploymentTemplate configures the Kubernetes
@@ -3198,6 +3200,11 @@ spec:
31983200
type: string
31993201
type: object
32003202
type: object
3203+
shardBaseURL:
3204+
description: |-
3205+
ShardBaseURL is the base URL under which this shard should be reachable. This is used to configure
3206+
the external URL. If not provided, the operator will use kubernetes service address to generate it.
3207+
type: string
32013208
required:
32023209
- cache
32033210
- certificates

config/crd/bases/operator.kcp.io_shards.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ spec:
428428
certificates for this shard.
429429
type: object
430430
clusterDomain:
431+
description: ClusterDomain is the DNS domain for services in the cluster.
432+
Defaults to "cluster.local" if not set.
431433
type: string
432434
deploymentTemplate:
433435
description: 'Optional: DeploymentTemplate configures the Kubernetes
@@ -1702,6 +1704,11 @@ spec:
17021704
type: string
17031705
type: object
17041706
type: object
1707+
shardBaseURL:
1708+
description: |-
1709+
ShardBaseURL is the base URL under which this shard should be reachable. This is used to configure
1710+
the external URL. If not provided, the operator will use kubernetes service address to generate it.
1711+
type: string
17051712
required:
17061713
- etcd
17071714
- rootShard

hack/ci/kernel.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: kernel-limits
5+
namespace: default
6+
spec:
7+
template:
8+
spec:
9+
containers:
10+
- name: init
11+
image: alpine:3.14
12+
command:
13+
- /bin/sh
14+
- -xc
15+
- |
16+
sysctl fs.inotify.max_user_watches=1048576
17+
sysctl fs.inotify.max_user_instances=1024
18+
securityContext:
19+
privileged: true
20+
restartPolicy: Never
21+
backoffLimit: 1

hack/ci/run-e2e-tests.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ echo "Creating kind cluster $KIND_CLUSTER_NAME..."
6363
kind create cluster --name "$KIND_CLUSTER_NAME" --image kindest/node:v1.32.2
6464
chmod 600 "$KUBECONFIG"
6565

66+
# apply kernel limits job first and wait for completion
67+
echo "Applying kernel limits job…"
68+
kubectl apply --filename hack/ci/kernel.yaml
69+
kubectl wait --for=condition=Complete job/kernel-limits --timeout=300s
70+
echo "Kernel limits job completed."
71+
6672
# store logs as artifacts
6773
make protokol
6874
_tools/protokol --output "$ARTIFACTS/logs" --namespace 'kcp-*' --namespace 'e2e-*' >/dev/null 2>&1 &
@@ -109,6 +115,9 @@ WHAT="${WHAT:-./test/e2e/...}"
109115
TEST_ARGS="${TEST_ARGS:--timeout 2h -v}"
110116
E2E_PARALLELISM=${E2E_PARALLELISM:-2}
111117

118+
# Increase file descriptor limit for CI environments
119+
ulimit -n 65536
120+
112121
(set -x; go test -tags e2e -parallel $E2E_PARALLELISM $TEST_ARGS "$WHAT")
113122

114123
echo "Done. :-)"

hack/run-e2e-tests.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ fi
5858

5959
echo "Kubeconfig is in $KUBECONFIG."
6060

61+
# apply kernel limits job first and wait for completion
62+
echo "Applying kernel limits job…"
63+
kubectl apply --filename hack/ci/kernel.yaml
64+
kubectl wait --for=condition=Complete job/kernel-limits --timeout=300s
65+
echo "Kernel limits job completed."
66+
6167
# deploying operator CRDs
6268
echo "Deploying operator CRDs..."
6369
kubectl apply --kustomize config/crd

internal/resources/resources.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ func GetRootShardBaseHost(r *operatorv1alpha1.RootShard) string {
117117
}
118118

119119
func GetRootShardBaseURL(r *operatorv1alpha1.RootShard) string {
120+
if r.Spec.ShardBaseURL != "" {
121+
return r.Spec.ShardBaseURL
122+
}
120123
return fmt.Sprintf("https://%s:6443", GetRootShardBaseHost(r))
121124
}
122125

@@ -130,6 +133,9 @@ func GetShardBaseHost(s *operatorv1alpha1.Shard) string {
130133
}
131134

132135
func GetShardBaseURL(s *operatorv1alpha1.Shard) string {
136+
if s.Spec.ShardBaseURL != "" {
137+
return s.Spec.ShardBaseURL
138+
}
133139
return fmt.Sprintf("https://%s:6443", GetShardBaseHost(s))
134140
}
135141

sdk/apis/operator/v1alpha1/shard_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ type ShardSpec struct {
2929
}
3030

3131
type CommonShardSpec struct {
32+
// ClusterDomain is the DNS domain for services in the cluster. Defaults to "cluster.local" if not set.
33+
// +optional
3234
ClusterDomain string `json:"clusterDomain,omitempty"`
3335

36+
// ShardBaseURL is the base URL under which this shard should be reachable. This is used to configure
37+
// the external URL. If not provided, the operator will use kubernetes service address to generate it.
38+
// +optional
39+
ShardBaseURL string `json:"shardBaseURL,omitempty"`
40+
3441
// Etcd configures the etcd cluster that this shard should be using.
3542
Etcd EtcdConfig `json:"etcd"`
3643

sdk/applyconfiguration/operator/v1alpha1/certificateissuerref.go

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/applyconfiguration/operator/v1alpha1/commonshardspec.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/applyconfiguration/operator/v1alpha1/rootshardspec.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)