-
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.
feat: create nginx-cluster controller with @kubekit/sync examples
- Loading branch information
1 parent
d4dcdcc
commit f6f1ad6
Showing
45 changed files
with
128,943 additions
and
5,470 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
53 changes: 53 additions & 0 deletions
53
examples/nginx-cluster-controller-with-kubekit-sync/README.md
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,53 @@ | ||
# Node.js + @kubekit/sync + @kubekit/client-gen Example | ||
|
||
This example demonstrates how to set up a Node.js application using [@kubekit/sync](../../packages/kubekit-sync) and [@kubekit/client-gen](../../packages/kubekit-client-gen) for managing Kubernetes resources and generating code. | ||
|
||
## Prerequisites | ||
|
||
- Node.js installed | ||
- Kubernetes cluster (e.g., Minikube, EKS, GKE) | ||
- kubectl configured to interact with your Kubernetes cluster | ||
|
||
## Usage | ||
|
||
yarn install | ||
kind create cluster -n nodejs-sync | ||
kubectl apply -f config/crds/nginxcluster.yaml | ||
|
||
```yaml | ||
cat <<EOF | kubectl apply -f - | ||
apiVersion: kubekit.com/v1 | ||
kind: NginxCluster | ||
metadata: | ||
name: my-nginx-cluster1 | ||
namespace: default | ||
spec: | ||
replicas: 5 | ||
resources: | ||
limits: | ||
cpu: "500m" | ||
memory: "512Mi" | ||
requests: | ||
cpu: "250m" | ||
memory: "256Mi" | ||
--- | ||
apiVersion: kubekit.com/v1 | ||
kind: NginxCluster | ||
metadata: | ||
name: my-nginx-cluster2 | ||
namespace: default | ||
spec: | ||
replicas: 2 | ||
resources: | ||
limits: | ||
cpu: "500m" | ||
memory: "512Mi" | ||
requests: | ||
cpu: "250m" | ||
memory: "256Mi" | ||
EOF | ||
``` | ||
|
||
npm run dev | ||
|
||
kind delete cluster -n nodejs-sync |
9 changes: 9 additions & 0 deletions
9
examples/nginx-cluster-controller-with-kubekit-sync/config/coordination-v1.ts
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 @@ | ||
import type { ConfigFile } from '@kubekit/client-gen' | ||
|
||
const config: ConfigFile = { | ||
schemaFile: '../openapi/apis/coordination.k8s.io/v1/swagger.json', | ||
apiFile: '@kubekit/client', | ||
outputFile: '../src/coordination-v1.ts', | ||
} | ||
|
||
export default config |
9 changes: 9 additions & 0 deletions
9
examples/nginx-cluster-controller-with-kubekit-sync/config/core-v1.ts
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 @@ | ||
import type { ConfigFile } from '@kubekit/client-gen' | ||
|
||
const config: ConfigFile = { | ||
schemaFile: '../openapi/api/v1/swagger.json', | ||
apiFile: '@kubekit/client', | ||
outputFile: '../src/core-v1.ts', | ||
} | ||
|
||
export default config |
54 changes: 54 additions & 0 deletions
54
examples/nginx-cluster-controller-with-kubekit-sync/config/crds/nginxcluster.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,54 @@ | ||
# generated by GPT-4o | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: nginxclusters.kubekit.com | ||
spec: | ||
group: kubekit.com | ||
versions: | ||
- name: v1 | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} | ||
schema: | ||
openAPIV3Schema: | ||
type: object | ||
properties: | ||
spec: | ||
type: object | ||
properties: | ||
replicas: | ||
type: integer | ||
resources: | ||
type: object | ||
properties: | ||
limits: | ||
type: object | ||
properties: | ||
cpu: | ||
type: string | ||
memory: | ||
type: string | ||
requests: | ||
type: object | ||
properties: | ||
cpu: | ||
type: string | ||
memory: | ||
type: string | ||
status: | ||
type: object | ||
properties: | ||
ready: | ||
type: boolean | ||
default: false | ||
default: | ||
ready: false | ||
scope: Namespaced | ||
names: | ||
plural: nginxclusters | ||
singular: nginxcluster | ||
kind: NginxCluster | ||
shortNames: | ||
- nc |
9 changes: 9 additions & 0 deletions
9
examples/nginx-cluster-controller-with-kubekit-sync/config/kubekit-v1.ts
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 @@ | ||
import type { ConfigFile } from '@kubekit/client-gen' | ||
|
||
const config: ConfigFile = { | ||
schemaFile: '../openapi/apis/kubekit.com/v1/swagger.json', | ||
apiFile: '@kubekit/client', | ||
outputFile: '../src/kubekit-v1.ts', | ||
} | ||
|
||
export default config |
8 changes: 8 additions & 0 deletions
8
examples/nginx-cluster-controller-with-kubekit-sync/eslint.config.js
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 @@ | ||
export default [ | ||
{ | ||
plugins: ['autofix'], | ||
rules: { | ||
'autofix/no-unused-vars': 'error', | ||
}, | ||
}, | ||
] |
30 changes: 30 additions & 0 deletions
30
examples/nginx-cluster-controller-with-kubekit-sync/package.json
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,30 @@ | ||
{ | ||
"name": "nginx-cluster-controller-with-kubekit-sync", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"directories": { | ||
"test": "tests" | ||
}, | ||
"scripts": { | ||
"sync": "npx @kubekit/sync ./", | ||
"gen": "npm-run-all gen:*", | ||
"gen:core-v1": "npx @kubekit/client-gen config/core-v1.ts", | ||
"gen:kubekit-v1": "npx @kubekit/client-gen config/kubekit-v1.ts", | ||
"gen:coordination-v1": "npx @kubekit/client-gen config/coordination-v1.ts", | ||
"refresh": "kubectl apply -f config/crds/nginxcluster.yaml && npm run sync && npm run gen", | ||
"dev": "npx tsx src/main.ts" | ||
}, | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@kubekit/client": "0.1.18" | ||
}, | ||
"devDependencies": { | ||
"@kubekit/client-gen": "^0.1.0", | ||
"@kubekit/sync": "0.1.3", | ||
"esbuild": "^0.20.2", | ||
"esbuild-runner": "^2.2.2", | ||
"npm-run-all": "^4.1.5" | ||
} | ||
} |
Oops, something went wrong.