forked from brancz/kube-rbac-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: enable to disable, limit http2 resources
- close HTTP/2 connections on unauthenticatead users - set max streams per connection to 100 - set max frame size and stream buffer to 256 kb. - enable to disable HTTP/2 compeltely
- Loading branch information
Showing
13 changed files
with
299 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
Copyright 2023 the kube-rbac-proxy maintainers. All rights reserved. | ||
Licensed 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 e2e | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/brancz/kube-rbac-proxy/test/kubetest" | ||
"k8s.io/client-go/kubernetes" | ||
) | ||
|
||
func testHTTP2(client kubernetes.Interface) kubetest.TestSuite { | ||
return func(t *testing.T) { | ||
command := `HTTP_VERSION=$(curl -sI --http2 --connect-timeout 5 -k --fail -w "%{http_version}\n" -o /dev/null https://kube-rbac-proxy.default.svc.cluster.local:8443/metrics); if [[ "$HTTP_VERSION" != "2" ]]; then echo "Did expect HTTP/2. Actual protocol: $HTTP_VERSION" > /proc/self/fd/2; exit 1; fi` | ||
|
||
kubetest.Scenario{ | ||
Name: "With succeeding HTTP2-client", | ||
Description: ` | ||
Expecting http/2 capable client to succeed to connect with http/2. | ||
`, | ||
|
||
Given: kubetest.Actions( | ||
kubetest.CreatedManifests( | ||
client, | ||
"http2/clusterRole.yaml", | ||
"http2/clusterRoleBinding.yaml", | ||
"http2/deployment.yaml", | ||
"http2/service.yaml", | ||
"http2/serviceAccount.yaml", | ||
"http2/clusterRole-client.yaml", | ||
"http2/clusterRoleBinding-client.yaml", | ||
), | ||
), | ||
When: kubetest.Actions( | ||
kubetest.PodsAreReady( | ||
client, | ||
1, | ||
"app=kube-rbac-proxy", | ||
), | ||
kubetest.ServiceIsReady( | ||
client, | ||
"kube-rbac-proxy", | ||
), | ||
), | ||
Then: kubetest.Actions( | ||
kubetest.ClientSucceeds( | ||
client, | ||
command, | ||
nil, | ||
), | ||
), | ||
}.Run(t) | ||
|
||
kubetest.Scenario{ | ||
Name: "With failing HTTP2-client", | ||
Description: ` | ||
Expecting http/2 capable client to fail to connect with http/2. | ||
`, | ||
|
||
Given: kubetest.Actions( | ||
kubetest.CreatedManifests( | ||
client, | ||
"http2/clusterRole.yaml", | ||
"http2/clusterRoleBinding.yaml", | ||
"http2/deployment-no-http2.yaml", | ||
"http2/service.yaml", | ||
"http2/serviceAccount.yaml", | ||
"http2/clusterRole-client.yaml", | ||
"http2/clusterRoleBinding-client.yaml", | ||
), | ||
), | ||
When: kubetest.Actions( | ||
kubetest.PodsAreReady( | ||
client, | ||
1, | ||
"app=kube-rbac-proxy", | ||
), | ||
kubetest.ServiceIsReady( | ||
client, | ||
"kube-rbac-proxy", | ||
), | ||
), | ||
Then: kubetest.Actions( | ||
kubetest.ClientFails( | ||
client, | ||
command, | ||
nil, | ||
), | ||
), | ||
}.Run(t) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: metrics | ||
rules: | ||
- nonResourceURLs: ["/metrics"] | ||
verbs: ["get"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: kube-rbac-proxy | ||
namespace: default | ||
rules: | ||
- apiGroups: ["authentication.k8s.io"] | ||
resources: | ||
- tokenreviews | ||
verbs: ["create"] | ||
- apiGroups: ["authorization.k8s.io"] | ||
resources: | ||
- subjectaccessreviews | ||
verbs: ["create"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: metrics | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: metrics | ||
subjects: | ||
- kind: ServiceAccount | ||
name: default | ||
namespace: default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: kube-rbac-proxy | ||
namespace: default | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: kube-rbac-proxy | ||
subjects: | ||
- kind: ServiceAccount | ||
name: kube-rbac-proxy | ||
namespace: default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: kube-rbac-proxy | ||
namespace: default | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: kube-rbac-proxy | ||
template: | ||
metadata: | ||
labels: | ||
app: kube-rbac-proxy | ||
spec: | ||
serviceAccountName: kube-rbac-proxy | ||
containers: | ||
- name: kube-rbac-proxy | ||
image: quay.io/brancz/kube-rbac-proxy:local | ||
args: | ||
- "--secure-listen-address=0.0.0.0:8443" | ||
- "--upstream=http://127.0.0.1:8081/" | ||
- "--ignore-paths=/metrics,/api/v1/*" | ||
- "--logtostderr=true" | ||
- "--http2-disable=true" | ||
- "--v=10" | ||
ports: | ||
- containerPort: 8443 | ||
name: https | ||
- name: prometheus-example-app | ||
image: quay.io/brancz/prometheus-example-app:v0.1.0 | ||
args: | ||
- "--bind=127.0.0.1:8081" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: kube-rbac-proxy | ||
namespace: default | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: kube-rbac-proxy | ||
template: | ||
metadata: | ||
labels: | ||
app: kube-rbac-proxy | ||
spec: | ||
serviceAccountName: kube-rbac-proxy | ||
containers: | ||
- name: kube-rbac-proxy | ||
image: quay.io/brancz/kube-rbac-proxy:local | ||
args: | ||
- "--secure-listen-address=0.0.0.0:8443" | ||
- "--upstream=http://127.0.0.1:8081/" | ||
- "--ignore-paths=/metrics,/api/v1/*" | ||
- "--logtostderr=true" | ||
- "--v=10" | ||
ports: | ||
- containerPort: 8443 | ||
name: https | ||
- name: prometheus-example-app | ||
image: quay.io/brancz/prometheus-example-app:v0.1.0 | ||
args: | ||
- "--bind=127.0.0.1:8081" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: kube-rbac-proxy | ||
name: kube-rbac-proxy | ||
namespace: default | ||
spec: | ||
ports: | ||
- name: https | ||
port: 8443 | ||
targetPort: https | ||
selector: | ||
app: kube-rbac-proxy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: kube-rbac-proxy | ||
namespace: default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters