-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from denis-tingaikin/add-kind-selfhost
Add kind selfhost example
- Loading branch information
Showing
6 changed files
with
199 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: ci | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
kind-selfhost: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
steps: | ||
- name: "Checkout repository" | ||
uses: actions/checkout@v4 | ||
with: | ||
path: ${{ github.workspace }}/src/github.com/${{ github.repository }} | ||
|
||
- name: "Install kind" | ||
run: | | ||
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.26.0/kind-linux-amd64 | ||
# For ARM64 | ||
[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.26.0/kind-linux-arm64 | ||
chmod +x ./kind | ||
sudo mv ./kind /usr/local/bin/kind | ||
- name: "Setup k8s cluster" | ||
run: | | ||
cat <<EOF | kind create cluster --wait=3m --config=- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
extraPortMappings: | ||
- containerPort: 80 | ||
hostPort: 80 | ||
protocol: TCP | ||
- containerPort: 443 | ||
hostPort: 443 | ||
protocol: TCP | ||
EOF | ||
- name: "Print cluster details" | ||
run: | | ||
kubectl cluster-info | ||
kubectl version | ||
kubectl get pods -n kube-system | ||
echo "current-context:" $(kubectl config current-context) | ||
echo "environment-kubeconfig:" ${KUBECONFIG} | ||
- name: "Install nginx ingress controller" | ||
run: | | ||
kubectl apply -f https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx.yaml | ||
kubectl wait --namespace ingress-nginx \ | ||
--for=condition=ready pod \ | ||
--selector=app.kubernetes.io/component=controller \ | ||
--timeout=90s | ||
- name: "Huly deploy" | ||
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}/kube | ||
run: | | ||
echo 127.0.0.1 huly.example | sudo tee -a /etc/hosts | ||
echo 127.0.0.1 account.huly.example | sudo tee -a /etc/hosts | ||
kubectl apply -R -f . | ||
kubectl wait --for=condition=Available deployment/mongodb --timeout 3m | ||
kubectl wait --for=condition=Available deployment/transactor --timeout 3m | ||
kubectl delete pod -l app=account | ||
kubectl wait --for=condition=Available deployment/account --timeout 3m | ||
- name: "Check login" | ||
run: | | ||
token=$(curl -v -H 'Content-Type: application/json' \ | ||
-d '{"method":"createAccount","params":["user1","1234","user","1"]}' \ | ||
-X POST \ | ||
http://account.huly.example/ | jq -r '.result.token') | ||
curl -v http://account.huly.example/ \ | ||
-X POST \ | ||
-d '{"method":"getUserWorkspaces","params":[]}' \ | ||
-H 'Content-Type: application/json' \ | ||
-H 'Accept: */*' \ | ||
-H "Authorization: Bearer $token" | ||
- name: Cleanup resources | ||
if: ${{ success() || failure() || cancelled() }} | ||
run: | | ||
kubectl describe pods | ||
kind delete cluster |
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,97 @@ | ||
# Quick Start with Kind | ||
> [!NOTE] | ||
> kind does not require kubectl, but you will not be able to perform some of the examples in our docs without it. To install kubectl see the upstream kubectl installation docs. | ||
## Install | ||
|
||
**macOS:** | ||
```bash | ||
# For Intel Macs | ||
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.26.0/kind-darwin-amd64 | ||
# For M1 / ARM Macs | ||
[ $(uname -m) = arm64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.26.0/kind-darwin-arm64 | ||
chmod +x ./kind | ||
mv ./kind /some-dir-in-your-PATH/kind | ||
``` | ||
|
||
**Linux:** | ||
```bash | ||
# For AMD64 / x86_64 | ||
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.26.0/kind-linux-amd64 | ||
# For ARM64 | ||
[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.26.0/kind-linux-arm64 | ||
chmod +x ./kind | ||
sudo mv ./kind /usr/local/bin/kind | ||
``` | ||
|
||
## Setup cluster with port forwarding | ||
|
||
> [!NOTE] | ||
> On the host computer, `localhost:80` should be accessible. | ||
```bash | ||
cat <<EOF | kind create cluster --config=- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
extraPortMappings: | ||
- containerPort: 80 | ||
hostPort: 80 | ||
protocol: TCP | ||
- containerPort: 443 | ||
hostPort: 443 | ||
protocol: TCP | ||
EOF | ||
``` | ||
|
||
Deploy the ingress nginx controller: | ||
```bash | ||
kubectl apply -f https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx.yaml | ||
``` | ||
|
||
Wait the nginx controller to be ready: | ||
```bash | ||
kubectl wait --namespace ingress-nginx \ | ||
--for=condition=ready pod \ | ||
--selector=app.kubernetes.io/component=controller \ | ||
--timeout=90s | ||
``` | ||
|
||
Add host entries to be able to work with ingresses from the host machine: | ||
```bash | ||
sudo cp -p /etc/hosts /tmp/hosts | ||
echo "127.0.0.1 huly.example" | sudo tee -a /etc/hosts | ||
echo "127.0.0.1 account.huly.example" | sudo tee -a /etc/hosts | ||
``` | ||
|
||
Deploy Huly with `kubectl`: | ||
|
||
```bash | ||
kubectl apply -R -f . | ||
``` | ||
|
||
Wait until the front app is coming up: | ||
```bash | ||
kubectl wait --for=condition=Avaiable deployment/front --timeout 3m | ||
``` | ||
|
||
Now, launch your web and and (enjoy Huly!)[http://huly.example]! | ||
|
||
|
||
## Cleanup | ||
|
||
Restore hosts file: | ||
```bash | ||
sudo mv /tmp/hosts /etc/hosts | ||
``` | ||
|
||
Cleanup Huly: | ||
```bash | ||
kubectl delete -R -f . | ||
``` | ||
|
||
Delete kind cluster: | ||
```bash | ||
kind delete cluster | ||
``` |
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