Skip to content

Commit c3e4ec4

Browse files
committed
Merge branch 'feat/migrate-registry-to-ghcr' into feat/webhook-adc-validation
2 parents a003a3e + 65c6747 commit c3e4ec4

8 files changed

Lines changed: 186 additions & 39 deletions

File tree

.github/workflows/conformance-test.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
CONFORMANCE_TEST_REPORT_OUTPUT: /tmp/api7-ingress-controller-conformance-report.yaml
3636
timeout-minutes: 60
3737
runs-on: ubuntu-latest
38+
permissions:
39+
packages: read
40+
pull-requests: write
3841
steps:
3942
- name: Checkout
4043
uses: actions/checkout@v4
@@ -56,19 +59,12 @@ jobs:
5659
chmod 700 get_helm.sh
5760
./get_helm.sh
5861
59-
- name: Login to Registry
62+
- name: Login to GHCR
6063
uses: docker/login-action@v3
6164
with:
62-
registry: ${{ secrets.DOCKER_REGISTRY }}
63-
username: ${{ secrets.DOCKER_USERNAME }}
64-
password: ${{ secrets.DOCKER_PASSWORD }}
65-
66-
- name: Login to Private Registry
67-
uses: docker/login-action@v3
68-
with:
69-
registry: hkccr.ccs.tencentyun.com
70-
username: ${{ secrets.PRIVATE_DOCKER_USERNAME }}
71-
password: ${{ secrets.PRIVATE_DOCKER_PASSWORD }}
65+
registry: ghcr.io
66+
username: ${{ github.actor }}
67+
password: ${{ secrets.GITHUB_TOKEN }}
7268

7369
- name: Build images
7470
env:

.github/workflows/e2e-test-k8s.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
cases_subset:
3939
- v2
4040
runs-on: self-hosted
41+
permissions:
42+
contents: read
43+
packages: read
4144
steps:
4245
- name: Checkout
4346
uses: actions/checkout@v4
@@ -58,12 +61,12 @@ jobs:
5861
chmod 700 get_helm.sh
5962
./get_helm.sh
6063
61-
- name: Login to Private Registry
64+
- name: Login to GHCR
6265
uses: docker/login-action@v3
6366
with:
64-
registry: hkccr.ccs.tencentyun.com
65-
username: ${{ secrets.PRIVATE_DOCKER_USERNAME }}
66-
password: ${{ secrets.PRIVATE_DOCKER_PASSWORD }}
67+
registry: ghcr.io
68+
username: ${{ github.actor }}
69+
password: ${{ secrets.GITHUB_TOKEN }}
6770

6871
- name: Launch Kind Cluster
6972
env:

.github/workflows/e2e-test.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
- webhook
4242
fail-fast: false
4343
runs-on: ubuntu-latest
44+
permissions:
45+
contents: read
46+
packages: read
4447
steps:
4548
- name: Checkout
4649
uses: actions/checkout@v4
@@ -65,19 +68,12 @@ jobs:
6568
- name: Install ginkgo
6669
run: make install-ginkgo
6770

68-
- name: Login to Registry
71+
- name: Login to GHCR
6972
uses: docker/login-action@v3
7073
with:
71-
registry: ${{ secrets.DOCKER_REGISTRY }}
72-
username: ${{ secrets.DOCKER_USERNAME }}
73-
password: ${{ secrets.DOCKER_PASSWORD }}
74-
75-
- name: Login to Private Registry
76-
uses: docker/login-action@v3
77-
with:
78-
registry: hkccr.ccs.tencentyun.com
79-
username: ${{ secrets.PRIVATE_DOCKER_USERNAME }}
80-
password: ${{ secrets.PRIVATE_DOCKER_PASSWORD }}
74+
registry: ghcr.io
75+
username: ${{ github.actor }}
76+
password: ${{ secrets.GITHUB_TOKEN }}
8177

8278
- name: Build images
8379
env:

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,22 +202,22 @@ kind-down:
202202

203203
.PHONY: kind-load-images
204204
kind-load-images: pull-infra-images kind-load-ingress-image kind-load-adc-image
205-
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-gateway:dev --name $(KIND_NAME)
206-
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-dp-manager:$(DASHBOARD_VERSION) --name $(KIND_NAME)
207-
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-integrated:$(DASHBOARD_VERSION) --name $(KIND_NAME)
205+
@kind load docker-image ghcr.io/api7/api7-ee-3-gateway:dev --name $(KIND_NAME)
206+
@kind load docker-image ghcr.io/api7/api7-ee-dp-manager:$(DASHBOARD_VERSION) --name $(KIND_NAME)
207+
@kind load docker-image ghcr.io/api7/api7-ee-3-integrated:$(DASHBOARD_VERSION) --name $(KIND_NAME)
208208
@kind load docker-image kennethreitz/httpbin:latest --name $(KIND_NAME)
209209
@kind load docker-image jmalloc/echo-server:latest --name $(KIND_NAME)
210210
@kind load docker-image apache/apisix:dev --name $(KIND_NAME)
211211
@kind load docker-image openresty/openresty:1.27.1.2-4-bullseye-fat --name $(KIND_NAME)
212212

213213
.PHONY: kind-load-gateway-image
214214
kind-load-gateway-image:
215-
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-gateway:dev --name $(KIND_NAME)
215+
@kind load docker-image ghcr.io/api7/api7-ee-3-gateway:dev --name $(KIND_NAME)
216216

217217
.PHONY: kind-load-dashboard-images
218218
kind-load-dashboard-images:
219-
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-dp-manager:$(DASHBOARD_VERSION) --name $(KIND_NAME)
220-
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-integrated:$(DASHBOARD_VERSION) --name $(KIND_NAME)
219+
@kind load docker-image ghcr.io/api7/api7-ee-dp-manager:$(DASHBOARD_VERSION) --name $(KIND_NAME)
220+
@kind load docker-image ghcr.io/api7/api7-ee-3-integrated:$(DASHBOARD_VERSION) --name $(KIND_NAME)
221221

222222
.PHONY: kind-load-ingress-image
223223
kind-load-ingress-image:
@@ -231,9 +231,9 @@ kind-load-adc-image:
231231

232232
.PHONY: pull-infra-images
233233
pull-infra-images:
234-
@docker pull hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-gateway:dev
235-
@docker pull hkccr.ccs.tencentyun.com/api7-dev/api7-ee-dp-manager:$(DASHBOARD_VERSION)
236-
@docker pull hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-integrated:$(DASHBOARD_VERSION)
234+
@docker pull ghcr.io/api7/api7-ee-3-gateway:dev
235+
@docker pull ghcr.io/api7/api7-ee-dp-manager:$(DASHBOARD_VERSION)
236+
@docker pull ghcr.io/api7/api7-ee-3-integrated:$(DASHBOARD_VERSION)
237237
@docker pull kennethreitz/httpbin:latest
238238
@docker pull jmalloc/echo-server:latest
239239
@docker pull ghcr.io/api7/adc:dev

internal/adc/translator/httproute.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,9 @@ func (t *Translator) TranslateHTTPRoute(tctx *provider.TranslateContext, httpRou
572572

573573
t.AttachBackendTrafficPolicyToUpstream(backend.BackendRef, tctx.BackendTrafficPolicies, upstream)
574574
upstream.Nodes = upNodes
575-
upstream.Scheme = appProtocolToUpstreamScheme(protocol)
575+
if upstream.Scheme == "" {
576+
upstream.Scheme = appProtocolToUpstreamScheme(protocol)
577+
}
576578
var (
577579
kind string
578580
port int32
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package translator
19+
20+
import (
21+
"context"
22+
"testing"
23+
24+
"github.com/go-logr/logr"
25+
"github.com/stretchr/testify/assert"
26+
"github.com/stretchr/testify/require"
27+
corev1 "k8s.io/api/core/v1"
28+
discoveryv1 "k8s.io/api/discovery/v1"
29+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30+
"k8s.io/apimachinery/pkg/types"
31+
"k8s.io/utils/ptr"
32+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
33+
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
34+
35+
"github.com/apache/apisix-ingress-controller/api/v1alpha1"
36+
apiv2 "github.com/apache/apisix-ingress-controller/api/v2"
37+
"github.com/apache/apisix-ingress-controller/internal/provider"
38+
internaltypes "github.com/apache/apisix-ingress-controller/internal/types"
39+
)
40+
41+
func TestTranslateHTTPRouteUpstreamScheme(t *testing.T) {
42+
tests := []struct {
43+
name string
44+
appProtocol string
45+
policyScheme string
46+
wantScheme string
47+
}{
48+
{
49+
name: "preserves backend traffic policy scheme",
50+
appProtocol: internaltypes.AppProtocolHTTP,
51+
policyScheme: apiv2.SchemeHTTPS,
52+
wantScheme: apiv2.SchemeHTTPS,
53+
},
54+
{
55+
name: "falls back to app protocol when scheme is unset",
56+
appProtocol: internaltypes.AppProtocolWSS,
57+
wantScheme: apiv2.SchemeHTTPS,
58+
},
59+
}
60+
61+
for _, tt := range tests {
62+
t.Run(tt.name, func(t *testing.T) {
63+
translator := NewTranslator(logr.Discard())
64+
tctx := provider.NewDefaultTranslateContext(context.Background())
65+
66+
const (
67+
namespace = "default"
68+
serviceName = "backend"
69+
portName = "web"
70+
portNumber = int32(8443)
71+
)
72+
73+
serviceKey := types.NamespacedName{Namespace: namespace, Name: serviceName}
74+
tctx.Services[serviceKey] = &corev1.Service{
75+
ObjectMeta: metav1.ObjectMeta{
76+
Name: serviceName,
77+
Namespace: namespace,
78+
},
79+
Spec: corev1.ServiceSpec{
80+
Ports: []corev1.ServicePort{{
81+
Name: portName,
82+
Port: portNumber,
83+
AppProtocol: ptr.To(tt.appProtocol),
84+
}},
85+
},
86+
}
87+
tctx.EndpointSlices[serviceKey] = []discoveryv1.EndpointSlice{{
88+
ObjectMeta: metav1.ObjectMeta{
89+
Name: "backend-1",
90+
Namespace: namespace,
91+
},
92+
Ports: []discoveryv1.EndpointPort{{
93+
Name: ptr.To(portName),
94+
Port: ptr.To(portNumber),
95+
}},
96+
Endpoints: []discoveryv1.Endpoint{{
97+
Addresses: []string{"10.0.0.1"},
98+
Conditions: discoveryv1.EndpointConditions{
99+
Ready: ptr.To(true),
100+
},
101+
}},
102+
}}
103+
104+
if tt.policyScheme != "" {
105+
tctx.BackendTrafficPolicies[serviceKey] = &v1alpha1.BackendTrafficPolicy{
106+
ObjectMeta: metav1.ObjectMeta{
107+
Name: "backend-policy",
108+
Namespace: namespace,
109+
},
110+
Spec: v1alpha1.BackendTrafficPolicySpec{
111+
TargetRefs: []v1alpha1.BackendPolicyTargetReferenceWithSectionName{{
112+
LocalPolicyTargetReference: gatewayv1alpha2.LocalPolicyTargetReference{
113+
Name: gatewayv1alpha2.ObjectName(serviceName),
114+
Kind: gatewayv1alpha2.Kind(internaltypes.KindService),
115+
},
116+
}},
117+
Scheme: tt.policyScheme,
118+
},
119+
}
120+
}
121+
122+
route := &gatewayv1.HTTPRoute{
123+
ObjectMeta: metav1.ObjectMeta{
124+
Name: "demo",
125+
Namespace: namespace,
126+
},
127+
Spec: gatewayv1.HTTPRouteSpec{
128+
Rules: []gatewayv1.HTTPRouteRule{{
129+
BackendRefs: []gatewayv1.HTTPBackendRef{{
130+
BackendRef: gatewayv1.BackendRef{
131+
BackendObjectReference: gatewayv1.BackendObjectReference{
132+
Name: gatewayv1.ObjectName(serviceName),
133+
Port: ptr.To(gatewayv1.PortNumber(portNumber)),
134+
},
135+
},
136+
}},
137+
}},
138+
},
139+
}
140+
141+
result, err := translator.TranslateHTTPRoute(tctx, route)
142+
require.NoError(t, err)
143+
require.Len(t, result.Services, 1)
144+
require.NotNil(t, result.Services[0].Upstream)
145+
146+
assert.Equal(t, tt.wantScheme, result.Services[0].Upstream.Scheme)
147+
assert.Equal(t, "10.0.0.1", result.Services[0].Upstream.Nodes[0].Host)
148+
})
149+
}
150+
}

test/e2e/framework/api7_dashboard.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func init() {
4545
tmpl, err := template.New("values.yaml").Parse(`
4646
dashboard:
4747
image:
48-
repository: hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-integrated
48+
repository: ghcr.io/api7/api7-ee-3-integrated
4949
pullPolicy: IfNotPresent
5050
tag: {{ .Tag }}
5151
extraEnvVars:
@@ -61,7 +61,7 @@ dashboard:
6161
mountPath: /app/covdatafiles
6262
dp_manager:
6363
image:
64-
repository: hkccr.ccs.tencentyun.com/api7-dev/api7-ee-dp-manager
64+
repository: ghcr.io/api7/api7-ee-dp-manager
6565
pullPolicy: IfNotPresent
6666
tag: {{ .Tag }}
6767
extraEnvVars:

test/e2e/framework/manifests/dp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ spec:
181181
spec:
182182
#serviceAccountName: ginkgo
183183
containers:
184-
- image: hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-gateway:dev
184+
- image: ghcr.io/api7/api7-ee-3-gateway:dev
185185
imagePullPolicy: IfNotPresent
186186
env:
187187
{{- if not .TLSEnabled }}

0 commit comments

Comments
 (0)