You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/01/07 17:31:53 UTC
[GitHub] [camel-k] astefanutti opened a new pull request #2858: feat: Global HTTP proxy support
astefanutti opened a new pull request #2858:
URL: https://github.com/apache/camel-k/pull/2858
This PR applies the HTTP proxy configuration, provided by users or system-wide controllers, via the `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` environment variables, to all the workloads managed by the Camel K operator.
In order to configure the Maven processes accordingly, this PR rationalises the management of the user vs. platform Maven settings. The former is now generated from the IntegrationPlatform and other environment variables, into _global_ settings, while the user settings are left untouched. The merging of both settings is delegated to Maven, thus relying on the its de-facto standard mechanism.
TODO:
- [ ] Propagate the the `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` environment variables to the builder Pods
- [ ] Fix TLS handshake issue in e2e tests when using a self-signed certificate for the HTTPS proxy
- [ ] Add documentation
Fixes #2777
Fixes #1402
**Release Note**
```release-note
feat: Global HTTP proxy support
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] squakez commented on a change in pull request #2858: feat: Global HTTP proxy support
Posted by GitBox <gi...@apache.org>.
squakez commented on a change in pull request #2858:
URL: https://github.com/apache/camel-k/pull/2858#discussion_r780989400
##########
File path: pkg/controller/integrationplatform/initialize_test.go
##########
@@ -115,29 +115,3 @@ func TestTimeouts_Truncated(t *testing.T) {
assert.Equal(t, 5*time.Minute, answer.Status.Build.GetTimeout().Duration)
}
-
-func TestDefaultMavenSettingsApplied(t *testing.T) {
Review comment:
Any reason why this test was removed? I could not find an equivalent one for the new development.
##########
File path: pkg/util/maven/maven_settings.go
##########
@@ -34,30 +32,46 @@ import (
var DefaultMavenRepositories = "https://repo.maven.apache.org/maven2@id=central"
func (s Settings) MarshalBytes() ([]byte, error) {
- w := &bytes.Buffer{}
- w.WriteString(xml.Header)
-
- e := xml.NewEncoder(w)
- e.Indent("", " ")
-
- if err := e.Encode(s); err != nil {
- return []byte{}, err
- }
+ return util.EncodeXML(s)
+}
- return w.Bytes(), nil
+type SettingsOption interface {
+ apply(settings *Settings) error
}
-func NewSettings() Settings {
- return Settings{
+func NewSettings(options ...SettingsOption) (Settings, error) {
+ settings := Settings{
XMLName: xml.Name{Local: "settings"},
XMLNs: "http://maven.apache.org/SETTINGS/1.0.0",
XMLNsXsi: "http://www.w3.org/2001/XMLSchema-instance",
XsiSchemaLocation: "http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd",
+ Profiles: []Profile{
+ {
+ ID: "camel-k",
+ Activation: Activation{
+ ActiveByDefault: true,
+ },
+ },
+ },
+ }
+
+ for _, option := range options {
+ err := option.apply(&settings)
+ if err != nil {
+ return Settings{}, err
+ }
}
+
+ return settings, nil
}
func NewDefaultSettings(repositories []v1.Repository, mirrors []Mirror) Settings {
- settings := NewSettings()
+ settings := Settings{
+ XMLName: xml.Name{Local: "settings"},
+ XMLNs: "http://maven.apache.org/SETTINGS/1.0.0",
Review comment:
All these are used at least twice, we could make them constants
##########
File path: e2e/common/build/maven_http_proxy_test.go
##########
@@ -0,0 +1,337 @@
+//go:build integration
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
+
+/*
+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.
+*/
+
+package build
+
+import (
+ "crypto/rand"
+ "crypto/rsa"
+ "crypto/x509"
+ "crypto/x509/pkix"
+ "encoding/pem"
+ "fmt"
+ "math/big"
+ rand2 "math/rand"
+ "strings"
+ "testing"
+ "time"
+
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/gstruct"
+
+ appsv1 "k8s.io/api/apps/v1"
+ corev1 "k8s.io/api/core/v1"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/apimachinery/pkg/util/intstr"
+
+ . "github.com/apache/camel-k/e2e/support"
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+)
+
+func TestMavenProxy(t *testing.T) {
+ WithNewTestNamespace(t, func(ns string) {
+ hostname := fmt.Sprintf("%s.%s.svc", "proxy", ns)
+ tlsMountPath := "/etc/tls/private"
+
+ // Generate the TLS certificate
+ serialNumber := big.NewInt(rand2.Int63())
+ cert := &x509.Certificate{
+ SerialNumber: serialNumber,
+ Subject: pkix.Name{
+ Organization: []string{"Camel K test"},
+ },
+ DNSNames: []string{hostname},
+ NotBefore: time.Now(),
+ NotAfter: time.Now().AddDate(1, 0, 0),
+ ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
+ KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
+ BasicConstraintsValid: true,
+ }
+
+ // generate the certificate private key
+ certPrivateKey, err := rsa.GenerateKey(rand.Reader, 2048)
+ Expect(err).To(BeNil())
+
+ privateKeyBytes := x509.MarshalPKCS1PrivateKey(certPrivateKey)
+ // encode for storing into a Secret
+ privateKeyPem := pem.EncodeToMemory(
+ &pem.Block{
+ Type: "RSA PRIVATE KEY",
+ Bytes: privateKeyBytes,
+ },
+ )
+ certBytes, err := x509.CreateCertificate(rand.Reader, cert, cert, &certPrivateKey.PublicKey, certPrivateKey)
+ Expect(err).To(BeNil())
+
+ // encode for storing into a Secret
+ certPem := pem.EncodeToMemory(&pem.Block{
+ Type: "CERTIFICATE",
+ Bytes: certBytes,
+ })
+
+ secret := &corev1.Secret{
+ TypeMeta: metav1.TypeMeta{
+ Kind: "Secret",
+ APIVersion: corev1.SchemeGroupVersion.String(),
+ },
+ ObjectMeta: metav1.ObjectMeta{
+ Namespace: ns,
+ Name: "tls-secret",
+ },
+ Type: corev1.SecretTypeTLS,
+ Data: map[string][]byte{
+ corev1.TLSCertKey: certPem,
+ corev1.TLSPrivateKeyKey: privateKeyPem,
+ },
+ }
+ Expect(TestClient().Create(TestContext, secret)).To(Succeed())
+
+ // HTTPD configuration
+ config := &corev1.ConfigMap{
Review comment:
Nit: for readability purposes, I'd move all these object (configmap, secrets, ...) creation in a separate method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] astefanutti commented on a change in pull request #2858: feat: Global HTTP proxy support
Posted by GitBox <gi...@apache.org>.
astefanutti commented on a change in pull request #2858:
URL: https://github.com/apache/camel-k/pull/2858#discussion_r783092522
##########
File path: pkg/trait/jvm.go
##########
@@ -169,6 +171,59 @@ func (t *jvmTrait) Apply(e *Environment) error {
args = append(args, t.Options...)
}
+ // Translate HTTP proxy environment variables, that are set by the environment trait,
+ // into corresponding JVM system properties.
+ if HTTPProxy := envvar.Get(container.Env, "HTTP_PROXY"); HTTPProxy != nil {
+ u, err := url.Parse(HTTPProxy.Value)
+ if err != nil {
+ return err
+ }
+ if !util.StringSliceContainsAnyOf(t.Options, "http.proxyHost") {
+ args = append(args, fmt.Sprintf("-Dhttp.proxyHost=%q", u.Hostname()))
+ }
+ if port := u.Port(); !util.StringSliceContainsAnyOf(t.Options, "http.proxyPort") && port != "" {
+ args = append(args, fmt.Sprintf("-Dhttp.proxyPort=%q", u.Port()))
+ }
+ if user := u.User; !util.StringSliceContainsAnyOf(t.Options, "http.proxyUser") && user != nil {
+ args = append(args, fmt.Sprintf("-Dhttp.proxyUser=%q", user.Username()))
+ if password, ok := user.Password(); !util.StringSliceContainsAnyOf(t.Options, "http.proxyUser") && ok {
+ args = append(args, fmt.Sprintf("-Dhttp.proxyPassword=%q", password))
+ }
+ }
+ }
+
+ if HTTPSProxy := envvar.Get(container.Env, "HTTPS_PROXY"); HTTPSProxy != nil {
Review comment:
Sure, let's do this in a subsequent PR so as to have this one in the upcoming release.
##########
File path: pkg/util/maven/maven_proxies.go
##########
@@ -0,0 +1,89 @@
+/*
+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.
+*/
+
+package maven
+
+import (
+ "net/url"
+ "os"
+ "strings"
+)
+
+var ProxyFromEnvironment = proxyFromEnvironment{}
+
+type proxyFromEnvironment struct{}
+
+func (proxyFromEnvironment) apply(settings *Settings) error {
+ if httpProxy := os.Getenv("HTTP_PROXY"); httpProxy != "" {
+ proxy, err := parseProxyFromEnvVar(httpProxy)
+ if err != nil {
+ return err
+ }
+ proxy.ID = "http-proxy"
+ settings.Proxies = append(settings.Proxies, proxy)
+ }
+
+ if httpsProxy := os.Getenv("HTTPS_PROXY"); httpsProxy != "" {
Review comment:
Sure, let's do this in a subsequent PR so as to have this one in the upcoming release.
##########
File path: resources/traits.yaml
##########
@@ -810,22 +815,28 @@ traits:
- Knative
- OpenShift
description: 'The Mount trait can be used to configure volumes mounted on the Integration
- Pod. nolint: tagliatelle'
+ Pods. nolint: tagliatelle'
Review comment:
It's already rebased, but it's not fixing it locally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] astefanutti merged pull request #2858: feat: Global HTTP proxy support
Posted by GitBox <gi...@apache.org>.
astefanutti merged pull request #2858:
URL: https://github.com/apache/camel-k/pull/2858
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] astefanutti commented on a change in pull request #2858: feat: Global HTTP proxy support
Posted by GitBox <gi...@apache.org>.
astefanutti commented on a change in pull request #2858:
URL: https://github.com/apache/camel-k/pull/2858#discussion_r780998260
##########
File path: pkg/controller/integrationplatform/initialize_test.go
##########
@@ -115,29 +115,3 @@ func TestTimeouts_Truncated(t *testing.T) {
assert.Equal(t, 5*time.Minute, answer.Status.Build.GetTimeout().Duration)
}
-
-func TestDefaultMavenSettingsApplied(t *testing.T) {
Review comment:
The reason is that the logic being tested is not used anymore which voids the purpose of the test. The _user_ Maven settings aren't reconciled anymore.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] astefanutti commented on a change in pull request #2858: feat: Global HTTP proxy support
Posted by GitBox <gi...@apache.org>.
astefanutti commented on a change in pull request #2858:
URL: https://github.com/apache/camel-k/pull/2858#discussion_r781036971
##########
File path: pkg/util/maven/maven_settings.go
##########
@@ -34,30 +32,46 @@ import (
var DefaultMavenRepositories = "https://repo.maven.apache.org/maven2@id=central"
func (s Settings) MarshalBytes() ([]byte, error) {
- w := &bytes.Buffer{}
- w.WriteString(xml.Header)
-
- e := xml.NewEncoder(w)
- e.Indent("", " ")
-
- if err := e.Encode(s); err != nil {
- return []byte{}, err
- }
+ return util.EncodeXML(s)
+}
- return w.Bytes(), nil
+type SettingsOption interface {
+ apply(settings *Settings) error
}
-func NewSettings() Settings {
- return Settings{
+func NewSettings(options ...SettingsOption) (Settings, error) {
+ settings := Settings{
XMLName: xml.Name{Local: "settings"},
XMLNs: "http://maven.apache.org/SETTINGS/1.0.0",
XMLNsXsi: "http://www.w3.org/2001/XMLSchema-instance",
XsiSchemaLocation: "http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd",
+ Profiles: []Profile{
+ {
+ ID: "camel-k",
+ Activation: Activation{
+ ActiveByDefault: true,
+ },
+ },
+ },
+ }
+
+ for _, option := range options {
+ err := option.apply(&settings)
+ if err != nil {
+ return Settings{}, err
+ }
}
+
+ return settings, nil
}
func NewDefaultSettings(repositories []v1.Repository, mirrors []Mirror) Settings {
- settings := NewSettings()
+ settings := Settings{
+ XMLName: xml.Name{Local: "settings"},
+ XMLNs: "http://maven.apache.org/SETTINGS/1.0.0",
Review comment:
It's addressed with 2e7075bccb7758e1e12fac6128e9c01b78fec124. I forgot to mention it still is WIP with the list of TODOs documented in the PR description.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] squakez commented on a change in pull request #2858: feat: Global HTTP proxy support
Posted by GitBox <gi...@apache.org>.
squakez commented on a change in pull request #2858:
URL: https://github.com/apache/camel-k/pull/2858#discussion_r782961649
##########
File path: pkg/trait/jvm.go
##########
@@ -169,6 +171,59 @@ func (t *jvmTrait) Apply(e *Environment) error {
args = append(args, t.Options...)
}
+ // Translate HTTP proxy environment variables, that are set by the environment trait,
+ // into corresponding JVM system properties.
+ if HTTPProxy := envvar.Get(container.Env, "HTTP_PROXY"); HTTPProxy != nil {
+ u, err := url.Parse(HTTPProxy.Value)
+ if err != nil {
+ return err
+ }
+ if !util.StringSliceContainsAnyOf(t.Options, "http.proxyHost") {
+ args = append(args, fmt.Sprintf("-Dhttp.proxyHost=%q", u.Hostname()))
+ }
+ if port := u.Port(); !util.StringSliceContainsAnyOf(t.Options, "http.proxyPort") && port != "" {
+ args = append(args, fmt.Sprintf("-Dhttp.proxyPort=%q", u.Port()))
+ }
+ if user := u.User; !util.StringSliceContainsAnyOf(t.Options, "http.proxyUser") && user != nil {
+ args = append(args, fmt.Sprintf("-Dhttp.proxyUser=%q", user.Username()))
+ if password, ok := user.Password(); !util.StringSliceContainsAnyOf(t.Options, "http.proxyUser") && ok {
+ args = append(args, fmt.Sprintf("-Dhttp.proxyPassword=%q", password))
+ }
+ }
+ }
+
+ if HTTPSProxy := envvar.Get(container.Env, "HTTPS_PROXY"); HTTPSProxy != nil {
Review comment:
Nit: considering that it's the same behavior for HTTP, we may try to create a function, so, any maintenance would be simpler
##########
File path: resources/traits.yaml
##########
@@ -810,22 +815,28 @@ traits:
- Knative
- OpenShift
description: 'The Mount trait can be used to configure volumes mounted on the Integration
- Pod. nolint: tagliatelle'
+ Pods. nolint: tagliatelle'
Review comment:
Fixed in #2851 - if you rebase, you should have it fixed when regenerating the documentation
##########
File path: pkg/util/maven/maven_proxies.go
##########
@@ -0,0 +1,89 @@
+/*
+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.
+*/
+
+package maven
+
+import (
+ "net/url"
+ "os"
+ "strings"
+)
+
+var ProxyFromEnvironment = proxyFromEnvironment{}
+
+type proxyFromEnvironment struct{}
+
+func (proxyFromEnvironment) apply(settings *Settings) error {
+ if httpProxy := os.Getenv("HTTP_PROXY"); httpProxy != "" {
+ proxy, err := parseProxyFromEnvVar(httpProxy)
+ if err != nil {
+ return err
+ }
+ proxy.ID = "http-proxy"
+ settings.Proxies = append(settings.Proxies, proxy)
+ }
+
+ if httpsProxy := os.Getenv("HTTPS_PROXY"); httpsProxy != "" {
Review comment:
Nit: duplicated code could benefit a refactoring into a function
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] squakez commented on pull request #2858: feat: Global HTTP proxy support
Posted by GitBox <gi...@apache.org>.
squakez commented on pull request #2858:
URL: https://github.com/apache/camel-k/pull/2858#issuecomment-1008752247
> Great work! I've added some minor comments to the review. One last thing, I'd like to see some little documentation reflected. This is a nice user feature and we should not miss to document how to use it.
Sorry, I did not read the TODO list :) I'll have a further look when complete
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] squakez commented on a change in pull request #2858: feat: Global HTTP proxy support
Posted by GitBox <gi...@apache.org>.
squakez commented on a change in pull request #2858:
URL: https://github.com/apache/camel-k/pull/2858#discussion_r783173854
##########
File path: resources/traits.yaml
##########
@@ -810,22 +815,28 @@ traits:
- Knative
- OpenShift
description: 'The Mount trait can be used to configure volumes mounted on the Integration
- Pod. nolint: tagliatelle'
+ Pods. nolint: tagliatelle'
Review comment:
Yeah, I've spotted the problem and fixed in #2873
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] astefanutti commented on pull request #2858: feat: Global HTTP proxy support
Posted by GitBox <gi...@apache.org>.
astefanutti commented on pull request #2858:
URL: https://github.com/apache/camel-k/pull/2858#issuecomment-1010914715
> > Great work! I've added some minor comments to the review. One last thing, I'd like to see some little documentation reflected. This is a nice user feature and we should not miss to document how to use it.
>
> Sorry, I did not read the TODO list :) I'll have a further look when complete
@squakez this is ready in case you want to have another look.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] astefanutti commented on a change in pull request #2858: feat: Global HTTP proxy support
Posted by GitBox <gi...@apache.org>.
astefanutti commented on a change in pull request #2858:
URL: https://github.com/apache/camel-k/pull/2858#discussion_r782948826
##########
File path: e2e/common/build/maven_http_proxy_test.go
##########
@@ -0,0 +1,337 @@
+//go:build integration
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
+
+/*
+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.
+*/
+
+package build
+
+import (
+ "crypto/rand"
+ "crypto/rsa"
+ "crypto/x509"
+ "crypto/x509/pkix"
+ "encoding/pem"
+ "fmt"
+ "math/big"
+ rand2 "math/rand"
+ "strings"
+ "testing"
+ "time"
+
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/gstruct"
+
+ appsv1 "k8s.io/api/apps/v1"
+ corev1 "k8s.io/api/core/v1"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/apimachinery/pkg/util/intstr"
+
+ . "github.com/apache/camel-k/e2e/support"
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+)
+
+func TestMavenProxy(t *testing.T) {
+ WithNewTestNamespace(t, func(ns string) {
+ hostname := fmt.Sprintf("%s.%s.svc", "proxy", ns)
+ tlsMountPath := "/etc/tls/private"
+
+ // Generate the TLS certificate
+ serialNumber := big.NewInt(rand2.Int63())
+ cert := &x509.Certificate{
+ SerialNumber: serialNumber,
+ Subject: pkix.Name{
+ Organization: []string{"Camel K test"},
+ },
+ DNSNames: []string{hostname},
+ NotBefore: time.Now(),
+ NotAfter: time.Now().AddDate(1, 0, 0),
+ ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
+ KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
+ BasicConstraintsValid: true,
+ }
+
+ // generate the certificate private key
+ certPrivateKey, err := rsa.GenerateKey(rand.Reader, 2048)
+ Expect(err).To(BeNil())
+
+ privateKeyBytes := x509.MarshalPKCS1PrivateKey(certPrivateKey)
+ // encode for storing into a Secret
+ privateKeyPem := pem.EncodeToMemory(
+ &pem.Block{
+ Type: "RSA PRIVATE KEY",
+ Bytes: privateKeyBytes,
+ },
+ )
+ certBytes, err := x509.CreateCertificate(rand.Reader, cert, cert, &certPrivateKey.PublicKey, certPrivateKey)
+ Expect(err).To(BeNil())
+
+ // encode for storing into a Secret
+ certPem := pem.EncodeToMemory(&pem.Block{
+ Type: "CERTIFICATE",
+ Bytes: certBytes,
+ })
+
+ secret := &corev1.Secret{
+ TypeMeta: metav1.TypeMeta{
+ Kind: "Secret",
+ APIVersion: corev1.SchemeGroupVersion.String(),
+ },
+ ObjectMeta: metav1.ObjectMeta{
+ Namespace: ns,
+ Name: "tls-secret",
+ },
+ Type: corev1.SecretTypeTLS,
+ Data: map[string][]byte{
+ corev1.TLSCertKey: certPem,
+ corev1.TLSPrivateKeyKey: privateKeyPem,
+ },
+ }
+ Expect(TestClient().Create(TestContext, secret)).To(Succeed())
+
+ // HTTPD configuration
+ config := &corev1.ConfigMap{
Review comment:
It should be done with 8d69cd83351e77a529c81907ebe75be8c34b3899.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org