Skip to content

Commit

Permalink
Adding a webhook to externalproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
wjiec committed Dec 22, 2024
1 parent 81fa415 commit 5a01308
Show file tree
Hide file tree
Showing 61 changed files with 3,057 additions and 498 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/test-chart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Test Chart

on:
push:
pull_request:

jobs:
test-e2e:
name: Run on Ubuntu
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Install the latest version of kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- name: Verify kind installation
run: kind version

- name: Create kind cluster
run: kind create cluster

- name: Prepare mobius
run: |
go mod tidy
make docker-build IMG=mobius:v0.1.0
kind load docker-image mobius:v0.1.0
- name: Install Helm
run: |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Verify Helm installation
run: helm version

- name: Lint Helm Chart
run: |
helm lint ./dist/chart
- name: Install Helm chart for project
run: |
helm install my-release ./dist/chart --create-namespace --namespace mobius-system
- name: Check Helm release status
run: |
helm status my-release --namespace mobius-system
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.22 AS builder
FROM golang:1.23 AS builder
ARG TARGETOS
ARG TARGETARCH

Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
generate: controller-gen manifests ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: fmt
Expand Down Expand Up @@ -166,10 +166,10 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION)
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)

## Tool Versions
KUSTOMIZE_VERSION ?= v5.4.1
CONTROLLER_TOOLS_VERSION ?= v0.15.0
ENVTEST_VERSION ?= release-0.18
GOLANGCI_LINT_VERSION ?= v1.57.2
KUSTOMIZE_VERSION ?= v5.5.0
CONTROLLER_TOOLS_VERSION ?= v0.16.4
ENVTEST_VERSION ?= release-0.19
GOLANGCI_LINT_VERSION ?= v1.61.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
7 changes: 7 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
domain: laboys.org
layout:
- go.kubebuilder.io/v4
multigroup: true
plugins:
helm.kubebuilder.io/v1-alpha: {}
projectName: mobius
repo: github.com/wjiec/mobius
resources:
Expand All @@ -17,4 +20,8 @@ resources:
kind: ExternalProxy
path: github.com/wjiec/mobius/api/networking/v1alpha1
version: v1alpha1
webhooks:
defaulting: true
validation: true
webhookVersion: v1
version: "3"
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# mobius
[![Go Report Card](https://goreportcard.com/badge/github.com/wjiec/mobius)](https://goreportcard.com/report/github.com/wjiec/mobius)
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![CI](https://github.com/wjiec/mobius/actions/workflows/ci.yaml/badge.svg)](https://github.com/wjiec/mobius/actions/workflows/ci.yaml)


## Introduction

Mobius aims to better orchestrate services in a personal Homelab through kubernetes.

**Note: At the moment mobius is only aiming to serve my own Homelab needs and is in the
development phase, so the design and implementation logic will be changed very frequently.
If you are using the project or are interested in it, any suggestions or questions are welcome
(of course if you have a good idea and are also willing to provide PR, that's also very welcome!).**


## Getting Started

Expand All @@ -18,14 +24,20 @@ If you have Helm, you can deploy the mobius with the following command:
```bash
helm upgrade --install mobius-manager mobius-manager \
--repo https://wjiec.github.io/mobius \
--namespace mobius-manager --create-namespace
--namespace mobius-system --create-namespace
```

It will install the mobius in the mobius-manager namespace, creating that namespace if it doesn't already exist.
It will install the mobius in the mobius-system namespace, creating that namespace if it doesn't already exist.

### ExternalProxy

As the name suggests, ExternalProxy creates a unified abstraction for out-of-cluster services through Kubernetes, allowing
us to create services or Ingresses for these out-of-cluster services as if they were in-cluster resources.

### Configure a ExternalProxy
For example, I have some standalone services on my Homelab (TrueNas, openwrt) or something like that, and I'd like to
provide HTTPS ingress for those services via cert-manager or use names within the cluster to access specific services.

Create this manifests locally and update something to your own.
You can refer to the configuration below and update something to your own.
```yaml
apiVersion: networking.laboys.org/v1alpha1
kind: ExternalProxy
Expand All @@ -38,24 +50,13 @@ spec:
ports:
- name: http
port: 80
service:
type: ClusterIP
ports:
- name: http
port: 80
ingress:
rules:
- host: openwrt.home.lab
http:
paths:
- pathType: ImplementationSpecific
backend:
port:
name: http
tls:
- hosts:
- openwrt.home.lab
secretName: star-home-lab
- openwrt.home.lab
secretName: star-domain-com-tls
```
Expand Down
16 changes: 16 additions & 0 deletions api/networking/types.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2024 Jayson Wang.
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 networking

const (
Expand Down
Loading

0 comments on commit 5a01308

Please sign in to comment.