Merge pull request #257 from nasuiyile/master
fix proxy test
diff --git a/app/dubboctl/cmd/proxy.go b/app/dubboctl/cmd/proxy.go
index 54aa98b..f901ee1 100644
--- a/app/dubboctl/cmd/proxy.go
+++ b/app/dubboctl/cmd/proxy.go
@@ -20,6 +20,14 @@
import (
"context"
"fmt"
+<<<<<<< HEAD
+ "github.com/apache/dubbo-kubernetes/pkg/core"
+ "github.com/apache/dubbo-kubernetes/pkg/core/logger"
+ "github.com/apache/dubbo-kubernetes/pkg/util/proto"
+ "github.com/pkg/errors"
+ "go.uber.org/zap/zapcore"
+=======
+>>>>>>> b165c47df48705310408955be94d62e3675c974b
"io"
"os"
"path/filepath"
@@ -40,7 +48,6 @@
"github.com/apache/dubbo-kubernetes/pkg/config/app/dubboctl"
"github.com/apache/dubbo-kubernetes/pkg/core"
dubbo_cmd "github.com/apache/dubbo-kubernetes/pkg/core/cmd"
- "github.com/apache/dubbo-kubernetes/pkg/core/logger"
"github.com/apache/dubbo-kubernetes/pkg/core/resources/apis/mesh"
"github.com/apache/dubbo-kubernetes/pkg/core/resources/model"
"github.com/apache/dubbo-kubernetes/pkg/core/resources/model/rest"
@@ -97,7 +104,6 @@
func addProxy(opts dubbo_cmd.RunCmdOpts, cmd *cobra.Command) {
proxyArgs := DefaultProxyConfig()
-
cfg := proxyArgs.Config
var proxyResource model.Resource
arg := struct {
@@ -113,6 +119,11 @@
Short: "Commands related to proxy",
Long: "Commands help user to generate Ingress and Egress",
RunE: func(cmd *cobra.Command, args []string) error {
+
+ return nil
+ },
+ PreRunE: func(cmd *cobra.Command, args []string) error {
+ var err error
logger.InitCmdSugar(zapcore.AddSync(cmd.OutOrStdout()))
level, err := dubbo_log.ParseLogLevel(arg.logLevel)
if err != nil {
@@ -130,9 +141,6 @@
} else {
core.SetLogger(core.NewLogger(level))
}
- return nil
- },
- PreRunE: func(cmd *cobra.Command, args []string) error {
proxyTypeMap := map[string]model.ResourceType{
string(mesh_proto.IngressProxyType): mesh.ZoneIngressType,
string(mesh_proto.EgressProxyType): mesh.ZoneEgressType,
@@ -144,7 +152,7 @@
cfg.DataplaneRuntime.EnvoyLogLevel = proxyArgs.LogLevel.String()
}
- proxyResource, err := readResource(cmd, &cfg.DataplaneRuntime)
+ proxyResource, err = readResource(cmd, &cfg.DataplaneRuntime)
if err != nil {
runLog.Error(err, "failed to read policy", "proxyType", cfg.Dataplane.ProxyType)
return err
@@ -220,7 +228,7 @@
cmd.PersistentFlags().IntVar(&arg.maxBackups, "log-max-retained-files", 1000, "maximum number of the old log files to retain")
cmd.PersistentFlags().IntVar(&arg.maxSize, "log-max-size", 100, "maximum size in megabytes of a log file before it gets rotated")
cmd.PersistentFlags().IntVar(&arg.maxAge, "log-max-age", 30, "maximum number of days to retain old log files based on the timestamp encoded in their filename")
-
+ cmd.PersistentFlags().StringVar(&cfg.ControlPlane.URL, "cp-address", cfg.ControlPlane.URL, "URL of the Control Plane Dataplane Server. Example: https://localhost:5678")
proxyCmd.PersistentFlags().StringVar(&cfg.Dataplane.Name, "name", cfg.Dataplane.Name, "Name of the Dataplane")
proxyCmd.PersistentFlags().StringVar(&cfg.Dataplane.Mesh, "mesh", cfg.Dataplane.Mesh, "Mesh that Dataplane belongs to")
proxyCmd.PersistentFlags().StringVar(&cfg.Dataplane.ProxyType, "proxy-type", "dataplane", `type of the Dataplane ("dataplane", "ingress")`)
diff --git a/pkg/xds/bootstrap/template_v3.go b/pkg/xds/bootstrap/template_v3.go
index 71034f1..5fbc406 100644
--- a/pkg/xds/bootstrap/template_v3.go
+++ b/pkg/xds/bootstrap/template_v3.go
@@ -221,16 +221,16 @@
for _, r := range res.StaticResources.Clusters {
if r.Name == adsClusterName {
transport := &envoy_tls.UpstreamTlsContext{
- Sni: parameters.XdsHost,
+ Sni: parameters.XdsHost,
CommonTlsContext: &envoy_tls.CommonTlsContext{
- TlsParams: &envoy_tls.TlsParameters{
- TlsMinimumProtocolVersion: envoy_tls.TlsParameters_TLSv1_2,
- },
- ValidationContextType: &envoy_tls.CommonTlsContext_ValidationContextSdsSecretConfig{
- //ValidationContextSdsSecretConfig: &envoy_tls.SdsSecretConfig{
- // Name: tls.CpValidationCtx,
- //},
- },
+ //TlsParams: &envoy_tls.TlsParameters{
+ // TlsMinimumProtocolVersion: envoy_tls.TlsParameters_TLSv1_2,
+ //},
+ //ValidationContextType: &envoy_tls.CommonTlsContext_ValidationContextSdsSecretConfig{
+ //ValidationContextSdsSecretConfig: &envoy_tls.SdsSecretConfig{
+ // Name: tls.CpValidationCtx,
+ //},
+ //},
},
}
any, err := util_proto.MarshalAnyDeterministic(transport)
diff --git a/test/proxy/dp-bootstrap.yaml b/test/proxy/dp-bootstrap.yaml
new file mode 100644
index 0000000..a887e7b
--- /dev/null
+++ b/test/proxy/dp-bootstrap.yaml
@@ -0,0 +1,151 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+---
+apiVersion: v1
+kind: Namespace
+metadata:
+ name: dubbo-system
+ labels:
+ dubbo.apache/system-namespace: "true"
+---
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: dubbo-ingress
+ namespace: dubbo-system
+ labels:
+ app: dubbo-ingress
+ app.kubernetes.io/name: dubbo
+ app.kubernetes.io/instance: dubbo
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: dubbo-ingress
+ namespace: dubbo-system
+ labels:
+ app: dubbo-ingress
+ app.kubernetes.io/name: dubbo
+ app.kubernetes.io/instance: dubbo
+spec:
+ type: LoadBalancer
+ ports:
+ - port: 10001
+ protocol: TCP
+ targetPort: 10001
+ selector:
+ app: dubbo-ingress
+ app.kubernetes.io/name: dubbo
+ app.kubernetes.io/instance: dubbo
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: dubbo-ingress
+ namespace: dubbo-system
+ labels:
+ app: dubbo-ingress
+ app.kubernetes.io/name: dubbo
+ app.kubernetes.io/instance: dubbo
+spec:
+ strategy:
+ rollingUpdate:
+ maxSurge: 1
+ maxUnavailable: 0
+ replicas: 1
+ selector:
+ matchLabels:
+ app.kubernetes.io/name: dubbo
+ app.kubernetes.io/instance: dubbo
+ app: dubbo-ingress
+ template:
+ metadata:
+ annotations:
+ dubbo.io/ingress: enabled
+ labels:
+ app: dubbo-ingress
+ app.kubernetes.io/name: dubbo
+ app.kubernetes.io/instance: dubbo
+ spec:
+ hostNetwork: true
+ serviceAccountName: dubbo-ingress
+ automountServiceAccountToken: true
+ nodeSelector:
+ kubernetes.io/os: linux
+ terminationGracePeriodSeconds: 40
+ containers:
+ - name: ingress
+ image: "dubboctl/proxy:latest"
+ imagePullPolicy: IfNotPresent
+ args:
+ - --cp-address=http://127.0.0.1:5678
+ ports:
+ - containerPort: 10001
+ livenessProbe:
+ httpGet:
+ path: "/ready"
+ port: 9901
+ failureThreshold: 12
+ initialDelaySeconds: 60
+ periodSeconds: 5
+ successThreshold: 1
+ timeoutSeconds: 3
+ readinessProbe:
+ httpGet:
+ path: "/ready"
+ port: 9901
+ failureThreshold: 12
+ initialDelaySeconds: 1
+ periodSeconds: 5
+ successThreshold: 1
+ timeoutSeconds: 3
+ resources:
+ limits:
+ cpu: 1000m
+ memory: 512Mi
+ requests:
+ cpu: 50m
+ memory: 64Mi
+ volumeMounts:
+ - name: tmp
+ mountPath: /tmp
+ - name: ingress-config
+ mountPath: /config
+ volumes:
+ - name: tmp
+ emptyDir: { }
+ - name: ingress-config
+ configMap:
+ name: ingress-config
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: ingress-config
+ namespace: dubbo-system
+ labels:
+ app: dubbo-control-plane
+ app.kubernetes.io/name: dubbo
+ app.kubernetes.io/instance: dubbo
+data:
+ ingress.yaml: |
+ type: ZoneIngress
+ name: zoneingress-1
+ networking:
+ address: 192.168.0.1
+ port: 10001
+ advertisedAddress: 10.0.0.1
+ advertisedPort: 10000
\ No newline at end of file
diff --git a/test/proxy/dp.Dockerfile b/test/proxy/dp.Dockerfile
new file mode 100644
index 0000000..60b4c5a
--- /dev/null
+++ b/test/proxy/dp.Dockerfile
@@ -0,0 +1,67 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Build the image binary
+FROM golang:1.20.1-alpine3.17 as builder
+
+
+# Build argments
+ARG TARGETOS=linux
+ARG TARGETARCH=amd64
+ARG LDFLAGS="-s -w"
+ARG BUILD
+
+WORKDIR /go/src/github.com/apache/dubbo-kubernetes
+
+# Copy the Go Modules manifests
+COPY go.mod go.mod
+COPY go.sum go.sum
+
+#RUN if [[ "${PKGNAME}" == "authority" ]]; then apk --update add gcc libc-dev upx ca-certificates && update-ca-certificates; fi
+
+# cache deps before building and copying source so that we don't need to re-download as much
+# and so that source changes don't invalidate our downloaded layer
+RUN if [[ "${BUILD}" != "CI" ]]; then go env -w GOPROXY=https://goproxy.cn,direct; fi
+RUN go env
+RUN go mod download
+
+
+# Copy the go source
+COPY pkg pkg/
+COPY app app/
+COPY api api/
+COPY conf conf/
+COPY deploy deploy/
+COPY generate generate/
+COPY test/proxy/dp test/proxy/dp
+
+# Build
+RUN env
+RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="${LDFLAGS:- -s -w}" -a -o dubboctl /go/src/github.com/apache/dubbo-kubernetes/app/dubboctl/main.go
+
+FROM envoyproxy/envoy:v1.29.2
+
+
+
+# Build
+WORKDIR /
+ARG PKGNAME
+COPY --from=builder /go/src/github.com/apache/dubbo-kubernetes/dubboctl .
+COPY --from=builder /go/src/github.com/apache/dubbo-kubernetes/test/proxy/dp .
+#COPY --from=builder /go/src/github.com/apache/dubbo-kubernetes/conf/admin.yml .
+#ENV ADMIN_CONFIG_PATH=./admin.yml
+
+
+ENTRYPOINT ["./dubboctl", "proxy","--proxy-type=ingress","--dataplane-file=/ingress.yaml"]
diff --git a/test/proxy/dp/ingress.yaml b/test/proxy/dp/ingress.yaml
new file mode 100644
index 0000000..6080785
--- /dev/null
+++ b/test/proxy/dp/ingress.yaml
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+type: ZoneIngress
+name: zoneingress-1
+networking:
+ address: 192.168.0.1
+ port: 10001
+ advertisedAddress: 10.0.0.1
+ advertisedPort: 10000
\ No newline at end of file