-
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.
* Add kubernetes manifest Signed-off-by: S-mishina <[email protected]> * fix Kubernetes deeployment image tag & Add README.md Signed-off-by: S-mishina <[email protected]> * fix README.md Signed-off-by: S-mishina <[email protected]> --------- Signed-off-by: S-mishina <[email protected]>
- Loading branch information
Showing
9 changed files
with
242 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# intro | ||
|
||
## Docker | ||
|
||
```:terminal | ||
docker run -p 8080:8080 ghcr.io/s-mishina/flexiblemockserver:latest | ||
``` | ||
|
||
Currently, it will not work unless the custom rule file exists. | ||
|
||
## Docker-Compose | ||
|
||
## Kubernetes | ||
|
||
To use flexiblemockserver on Kubernetes, please follow the steps below. | ||
This document describes how to use [kind](https://kind.sigs.k8s.io/). | ||
|
||
### step 1 | ||
|
||
Create a cluster using kind. | ||
|
||
sample command | ||
|
||
```:terminal | ||
flexiblemockserver/sample_manifest/kubernetes(ap-northeast-1) | ||
❯ ls | ||
cluster.yaml flexiblemockserver | ||
``` | ||
|
||
```:terminal | ||
❯ kind create cluster -n sandbox-test --config cluster.yaml | ||
Creating cluster "sandbox-test" ... | ||
✓ Ensuring node image (kindest/node:v1.27.3) 🖼 | ||
✓ Preparing nodes 📦 📦 📦 📦 | ||
✓ Writing configuration 📜 | ||
✓ Starting control-plane 🕹️ | ||
✓ Installing CNI 🔌 | ||
✓ Installing StorageClass 💾 | ||
✓ Joining worker nodes 🚜 | ||
Set kubectl context to "kind-sandbox-test" | ||
You can now use your cluster with: | ||
kubectl cluster-info --context kind-sandbox-test | ||
Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community 🙂 | ||
``` | ||
|
||
### step 2 | ||
|
||
Please import the required IMAGE onto kind. | ||
|
||
sample command | ||
|
||
```:terminal | ||
❯ docker pull ghcr.io/s-mishina/flexiblemockserver:latest | ||
``` | ||
|
||
```:terminal | ||
❯ kind load docker-image ghcr.io/s-mishina/flexiblemockserver:latest ghcr.io/s-mishina/flexiblemockserver:latest -n sandbox-test | ||
Image: "ghcr.io/s-mishina/flexiblemockserver:latest" with ID "sha256:96b36be4d13881b2567a42662dd3a613649740348d0a360d0b686b7eb4c7798e" not yet present on node "sandbox-test-worker2", loading... | ||
Image: "ghcr.io/s-mishina/flexiblemockserver:latest" with ID "sha256:96b36be4d13881b2567a42662dd3a613649740348d0a360d0b686b7eb4c7798e" not yet present on node "sandbox-test-worker3", loading... | ||
Image: "ghcr.io/s-mishina/flexiblemockserver:latest" with ID "sha256:96b36be4d13881b2567a42662dd3a613649740348d0a360d0b686b7eb4c7798e" not yet present on node "sandbox-test-control-plane", loading... | ||
Image: "ghcr.io/s-mishina/flexiblemockserver:latest" with ID "sha256:96b36be4d13881b2567a42662dd3a613649740348d0a360d0b686b7eb4c7798e" not yet present on node "sandbox-test-worker", loading... | ||
``` | ||
|
||
### step 3 | ||
|
||
Finally, let's apply the manifest! | ||
|
||
```:terminal | ||
[kind-sandbox-test|default] :ctx | ||
[arm64]⚡️ | ||
flexiblemockserver/sample_manifest/kubernetes on feature/sandbox-k8s-manifest | ||
❯ ls | ||
cluster.yaml flexiblemockserver | ||
[kind-sandbox-test|default] :ctx | ||
[arm64]⚡️ | ||
flexiblemockserver/sample_manifest/kubernetes on feature/sandbox-k8s-manifest | ||
❯ kubectl apply -k flexiblemockserver | ||
namespace/mockserver created | ||
configmap/custom-rule created | ||
configmap/response created | ||
service/flexiblemockserver created | ||
deployment.apps/flexiblemockserver created | ||
``` | ||
|
||
### as necessary | ||
|
||
This document is intended to confirm the operation of ServiceMesh and Kuberneres. | ||
|
||
The following custom operator | ||
|
||
#### Reloader | ||
|
||
[document](https://github.com/stakater/Reloader?tab=readme-ov-file#vanilla-manifests) | ||
|
||
#### istio | ||
|
||
[document](https://istio.io/latest/docs/setup/install/istioctl/) | ||
|
||
|
Empty file.
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,8 @@ | ||
# cluster.yaml | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
- role: worker | ||
- role: worker | ||
- role: worker |
42 changes: 42 additions & 0 deletions
42
sample_manifest/kubernetes/flexiblemockserver/configmap.yaml
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,42 @@ | ||
# configmap | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: custom-rule | ||
namespace: mockserver | ||
annotations: | ||
reloader.stakater.com/match: "true" | ||
data: | ||
custom_rule.yaml: | | ||
custom_rule: | ||
- name: "Custom Rule" | ||
rule: | ||
path: "/example" | ||
method: "GET" | ||
status_code: 200 | ||
response_body_path: "config/json/response1.json" | ||
- name: "liveness" | ||
rule: | ||
path: "/liveness" | ||
method: "GET" | ||
status_code: 200 | ||
response_body_path: "config/json/response1.json" | ||
- name: "readiness" | ||
rule: | ||
path: "/readiness" | ||
method: "GET" | ||
status_code: 200 | ||
response_body_path: "config/json/response1.json" | ||
# ref: https://github.com/S-mishina/flexiblemockserver?tab=readme-ov-file#custom-rule | ||
--- | ||
# configmap | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: response | ||
namespace: test | ||
annotations: | ||
reloader.stakater.com/match: "true" | ||
data: | ||
response1.json: | | ||
{"response","Hello, World!"} |
59 changes: 59 additions & 0 deletions
59
sample_manifest/kubernetes/flexiblemockserver/deployment.yaml
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,59 @@ | ||
# deployment.yaml | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: flexiblemockserver | ||
namespace: mockserver | ||
annotations: | ||
configmap.reloader.stakater.com/reload: "*" | ||
spec: | ||
strategy: | ||
rollingUpdate: | ||
maxSurge: 25% | ||
maxUnavailable: 0 | ||
replicas: 4 | ||
selector: | ||
matchLabels: | ||
app: flexiblemockserver | ||
template: | ||
metadata: | ||
labels: | ||
app: flexiblemockserver | ||
istio-injection: enabled | ||
test: "test4" | ||
|
||
spec: | ||
containers: | ||
- name: flexiblemockserver | ||
image: ghcr.io/s-mishina/flexiblemockserver:latest | ||
imagePullPolicy: IfNotPresent | ||
ports: | ||
- containerPort: 8080 | ||
env: | ||
- name: CUSTOM_RULE_YAML_FILE | ||
value: config/custom_rule.yaml | ||
volumeMounts: | ||
- name: custom-rule | ||
mountPath: /config | ||
- name: response | ||
mountPath: /config/json | ||
volumes: | ||
- name: custom-rule | ||
configMap: | ||
name: custom-rule | ||
- name: response | ||
configMap: | ||
name: response | ||
# TODO: Set if Liveness rediness is required. | ||
# readinessProbe: | ||
# httpGet: | ||
# path: /readiness | ||
# port: 8080 | ||
# periodSeconds: 1 | ||
# failureThreshold: 1 | ||
# livenessProbe: | ||
# httpGet: | ||
# path: /liveness | ||
# port: 8080 | ||
# periodSeconds: 1 | ||
# failureThreshold: 1 |
9 changes: 9 additions & 0 deletions
9
sample_manifest/kubernetes/flexiblemockserver/kustomization.yaml
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,9 @@ | ||
# kustmize.yaml | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
namespace: mockserver | ||
resources: | ||
- deployment.yaml | ||
- configmap.yaml | ||
- service.yaml | ||
- namespace.yaml |
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 @@ | ||
# namespace.yaml | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: mockserver | ||
labels: | ||
istio-injection: enabled |
13 changes: 13 additions & 0 deletions
13
sample_manifest/kubernetes/flexiblemockserver/service.yaml
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 @@ | ||
# service.yaml | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: flexiblemockserver | ||
namespace: mockserver | ||
spec: | ||
selector: | ||
app: flexiblemockserver | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 8080 |