Skip to content

Commit

Permalink
Merge pull request #15 from zufardhiyaulhaq/implement-tls-host-header…
Browse files Browse the repository at this point in the history
…-bind-tls

add TLS protocol, implement host_header, and implement bind_tls
  • Loading branch information
zufardhiyaulhaq authored Sep 4, 2021
2 parents 8eed1c6 + f65c9cc commit 542f7d1
Show file tree
Hide file tree
Showing 33 changed files with 372 additions and 202 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ jobs:
version: "${{ matrix.kubernetes }}"
k3d-args: --no-lb
- name: deploy charts
run: helm install ngrok-operator ./charts/ngrok-operator --values ./charts/ngrok-operator/values.yaml --set operator.tag=latest
- run: sleep 30
- name: check charts installed
run: kubectl get pod
run: helm install ngrok-operator ./charts/ngrok-operator --values ./charts/ngrok-operator/values.yaml --set operator.tag=dev-ci
- name: deploy applications
run: kubectl apply -f ./examples/deployment
- name: deploy ngrok
run: kubectl apply -f ./examples/http/simple
- name: waiting ngrok-operator to start
run: sleep 180
- name: check ngrok object
run: kubectl get ngrok -A
11 changes: 8 additions & 3 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ jobs:
k3d-args: --no-lb
- name: deploy charts
run: helm install ngrok-operator ./charts/ngrok-operator --values ./charts/ngrok-operator/values.yaml --set operator.tag=dev-ci
- run: sleep 30
- name: check charts installed
run: kubectl get pod
- name: deploy applications
run: kubectl apply -f ./examples/deployment
- name: deploy ngrok
run: kubectl apply -f ./examples/http/simple
- name: waiting ngrok-operator to start
run: sleep 180
- name: check ngrok object
run: kubectl get ngrok -A
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Ngrok operator provide developer easy access to private Kubernetes cluster for testing purpose via ngrok. Automate the creation of ngrok tunnel via CRD and automatically reload ngrok session when expired!

![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.1.0](https://img.shields.io/badge/AppVersion-1.1.0-informational?style=flat-square) [![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org) [![Github master branch build](https://img.shields.io/github/workflow/status/zufardhiyaulhaq/ngrok-operator/Master)](https://github.com/zufardhiyaulhaq/ngrok-operator/actions/workflows/master.yml) [![GitHub issues](https://img.shields.io/github/issues/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/pulls)
![Version: 1.1.0](https://img.shields.io/badge/Version-1.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.0](https://img.shields.io/badge/AppVersion-1.2.0-informational?style=flat-square) [![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org) [![Github master branch build](https://img.shields.io/github/workflow/status/zufardhiyaulhaq/ngrok-operator/Master)](https://github.com/zufardhiyaulhaq/ngrok-operator/actions/workflows/master.yml) [![GitHub issues](https://img.shields.io/github/issues/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/pulls)

## Installing

Expand All @@ -16,23 +16,22 @@ helm install my-release zufardhiyaulhaq/ngrok-operator --values values.yaml
## Usage
1. Apply some example
```console
kubectl apply -f examples/nginx
kubectl apply -f examples/helloworld/namespace.yaml
kubectl apply -f examples/helloworld/
kubectl apply -f examples/deployment/
kubectl apply -f examples/http/simple/
kubectl apply -f examples/http/full-configuration/
```
2. Check ngrok object
```console
kubectl get ngrok --all-namespaces
NAMESPACE NAME STATUS URL
default nginx-ngrok created https://9496e56ed0bc.ngrok.io
default nginx-ngrok-full created https://ngrok.zufardhiyaulhaq.com
helloworld helloworld-ngrok created https://d00ba8cb0b95.ngrok.io
NAMESPACE NAME STATUS URL
default http-simple created https://9496e56ed0bc.ngrok.io
default http-full-configuration created https://ngrok.zufardhiyaulhaq.com
```

3. access the URL
```console
https://d5150f7c3588.ngrok.io
https://ngrok.zufardhiyaulhaq.com
https://fa03f71fbe18.ngrok.io/hello
```

## Values
Expand All @@ -41,5 +40,9 @@ https://fa03f71fbe18.ngrok.io/hello
|-----|------|---------|-------------|
| operator.image | string | `"zufardhiyaulhaq/ngrok-operator"` | |
| operator.replica | int | `1` | |
| operator.tag | string | `"v1.1.0"` | |
| operator.tag | string | `"v1.2.0"` | |
| resources.limits.cpu | string | `"200m"` | |
| resources.limits.memory | string | `"100Mi"` | |
| resources.requests.cpu | string | `"100m"` | |
| resources.requests.memory | string | `"20Mi"` | |

45 changes: 38 additions & 7 deletions api/v1alpha1/ngrok_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ limitations under the License.
package v1alpha1

import (
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// NgrokSpec defines the desired state of Ngrok
type NgrokSpec struct {
Service string `json:"service"`
Port int32 `json:"port"`
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=65535
Port int32 `json:"port"`

// +kubebuilder:validation:Enum=http;tcp
// +kubebuilder:validation:Enum=http;tcp;tls
// +kubebuilder:default:=http
// +optional
Protocol string `json:"protocol"`
Expand All @@ -38,29 +42,56 @@ type NgrokSpec struct {
// +optional
AuthTokenType string `json:"authtoken_type"`

// +kubebuilder:validation:Enum=us;eu;ap;au;sa;jp;in
// +optional
Auth string `json:"auth"`
Region string `json:"region"`

// +optional
Hostname string `json:"hostname"`
Auth string `json:"auth"`

// +optional
RemoteAddr string `json:"remote_addr"`
HostHeader string `json:"host_header"`

// +kubebuilder:validation:Enum=us;eu;ap;au;sa;jp;in
// +kubebuilder:validation:Enum=true;false;both
// +optional
Region string `json:"region"`
BindTLS string `json:"bind_tls"`

// +kubebuilder:validation:Enum=true;false
// +kubebuilder:default:=false
// +optional
Inspect bool `json:"inspect"`

// +optional
Hostname string `json:"hostname"`

// +optional
RemoteAddr string `json:"remote_addr"`

// +kubebuilder:default:={image: zufardhiyaulhaq/ngrok}
// +optional
PodSpec PodSpec `json:"podSpec"`
}

func (n *NgrokSpec) Validate() error {
if n.Protocol == "http" || n.Protocol == "tls" {
if n.Service == "" {
return fmt.Errorf("service invalid")
}
}

if n.AuthToken == "" && n.Protocol == "tls" {
return fmt.Errorf("protocol TLS only available in pro")
}

if n.Protocol == "tcp" {
if n.RemoteAddr == "" {
return fmt.Errorf("remote_addr invalid")
}
}

return nil
}

type PodSpec struct {
// +optional
Image string `json:"image"`
Expand Down
4 changes: 2 additions & 2 deletions charts/ngrok-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
apiVersion: v2
name: ngrok-operator
description: Ngrok operator provide developer easy access to private Kubernetes cluster for testing purpose via ngrok. Automate the creation of ngrok tunnel via CRD and automatically reload ngrok session when expired!
version: 1.0.0
appVersion: 1.1.0
version: 1.1.0
appVersion: 1.2.0
type: application
home: https://github.com/zufardhiyaulhaq/ngrok-operator

Expand Down
23 changes: 13 additions & 10 deletions charts/ngrok-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Ngrok operator provide developer easy access to private Kubernetes cluster for testing purpose via ngrok. Automate the creation of ngrok tunnel via CRD and automatically reload ngrok session when expired!

![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.1.0](https://img.shields.io/badge/AppVersion-1.1.0-informational?style=flat-square) [![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org) [![Github master branch build](https://img.shields.io/github/workflow/status/zufardhiyaulhaq/ngrok-operator/Master)](https://github.com/zufardhiyaulhaq/ngrok-operator/actions/workflows/master.yml) [![GitHub issues](https://img.shields.io/github/issues/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/pulls)
![Version: 1.1.0](https://img.shields.io/badge/Version-1.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.0](https://img.shields.io/badge/AppVersion-1.2.0-informational?style=flat-square) [![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org) [![Github master branch build](https://img.shields.io/github/workflow/status/zufardhiyaulhaq/ngrok-operator/Master)](https://github.com/zufardhiyaulhaq/ngrok-operator/actions/workflows/master.yml) [![GitHub issues](https://img.shields.io/github/issues/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/pulls)

## Installing

Expand All @@ -16,23 +16,22 @@ helm install my-release zufardhiyaulhaq/ngrok-operator --values values.yaml
## Usage
1. Apply some example
```console
kubectl apply -f examples/nginx
kubectl apply -f examples/helloworld/namespace.yaml
kubectl apply -f examples/helloworld/
kubectl apply -f examples/deployment/
kubectl apply -f examples/http/simple/
kubectl apply -f examples/http/full-configuration/
```
2. Check ngrok object
```console
kubectl get ngrok --all-namespaces
NAMESPACE NAME STATUS URL
default nginx-ngrok created https://9496e56ed0bc.ngrok.io
default nginx-ngrok-full created https://ngrok.zufardhiyaulhaq.com
helloworld helloworld-ngrok created https://d00ba8cb0b95.ngrok.io
NAMESPACE NAME STATUS URL
default http-simple created https://9496e56ed0bc.ngrok.io
default http-full-configuration created https://ngrok.zufardhiyaulhaq.com
```

3. access the URL
```console
https://d5150f7c3588.ngrok.io
https://ngrok.zufardhiyaulhaq.com
https://fa03f71fbe18.ngrok.io/hello
```

## Values
Expand All @@ -41,5 +40,9 @@ https://fa03f71fbe18.ngrok.io/hello
|-----|------|---------|-------------|
| operator.image | string | `"zufardhiyaulhaq/ngrok-operator"` | |
| operator.replica | int | `1` | |
| operator.tag | string | `"v1.1.0"` | |
| operator.tag | string | `"v1.2.0"` | |
| resources.limits.cpu | string | `"200m"` | |
| resources.limits.memory | string | `"100Mi"` | |
| resources.requests.cpu | string | `"100m"` | |
| resources.requests.memory | string | `"20Mi"` | |

15 changes: 7 additions & 8 deletions charts/ngrok-operator/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@ helm install my-release zufardhiyaulhaq/ngrok-operator --values values.yaml
## Usage
1. Apply some example
```console
kubectl apply -f examples/nginx
kubectl apply -f examples/helloworld/namespace.yaml
kubectl apply -f examples/helloworld/
kubectl apply -f examples/deployment/
kubectl apply -f examples/http/simple/
kubectl apply -f examples/http/full-configuration/
```
2. Check ngrok object
```console
kubectl get ngrok --all-namespaces
NAMESPACE NAME STATUS URL
default nginx-ngrok created https://9496e56ed0bc.ngrok.io
default nginx-ngrok-full created https://ngrok.zufardhiyaulhaq.com
helloworld helloworld-ngrok created https://d00ba8cb0b95.ngrok.io
NAMESPACE NAME STATUS URL
default http-simple created https://9496e56ed0bc.ngrok.io
default http-full-configuration created https://ngrok.zufardhiyaulhaq.com
```

3. access the URL
```console
https://d5150f7c3588.ngrok.io
https://ngrok.zufardhiyaulhaq.com
https://fa03f71fbe18.ngrok.io/hello
```

{{ template "chart.requirementsSection" . }}
Expand Down
11 changes: 11 additions & 0 deletions charts/ngrok-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ spec:
- plain
- secret
type: string
bind_tls:
enum:
- true
- false
- both
type: string
host_header:
type: string
hostname:
type: string
inspect:
Expand All @@ -72,12 +80,15 @@ spec:
type: object
port:
format: int32
maximum: 65535
minimum: 1
type: integer
protocol:
default: http
enum:
- http
- tcp
- tls
type: string
region:
enum:
Expand Down
2 changes: 1 addition & 1 deletion charts/ngrok-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ operator:
# image of ngrok-operator
image: "zufardhiyaulhaq/ngrok-operator"
# tag of ngrok-operator image
tag: "v1.1.0"
tag: "v1.2.0"
# number of replica for deployment
replica: 1

Expand Down
Binary file added charts/releases/ngrok-operator-1.1.0.tgz
Binary file not shown.
11 changes: 11 additions & 0 deletions config/crd/bases/ngrok.com_ngroks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ spec:
- plain
- secret
type: string
bind_tls:
enum:
- true
- false
- both
type: string
host_header:
type: string
hostname:
type: string
inspect:
Expand All @@ -72,12 +80,15 @@ spec:
type: object
port:
format: int32
maximum: 65535
minimum: 1
type: integer
protocol:
default: http
enum:
- http
- tcp
- tls
type: string
region:
enum:
Expand Down
2 changes: 1 addition & 1 deletion controllers/ngrok_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (r *NgrokReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
}

log.Info("Build configuration")
configuration, err := builder.NewNgrokConfigurationBuilder(r.Client).
configuration, err := builder.NewNgrokConfigurationBuilder().
SetSpec(spec).
Build()
if err != nil {
Expand Down
19 changes: 0 additions & 19 deletions examples/authtoken-secret/ngrok.yaml

This file was deleted.

File renamed without changes.
File renamed without changes.
20 changes: 0 additions & 20 deletions examples/helloworld/deployment.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions examples/helloworld/namespace.yaml

This file was deleted.

Loading

0 comments on commit 542f7d1

Please sign in to comment.