Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyoung committed Oct 23, 2023
1 parent 4e17b29 commit 9fc7da2
Show file tree
Hide file tree
Showing 11 changed files with 327 additions and 1 deletion.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,39 @@ kubectl create -f https://raw.githubusercontent.com/uengine-oss/kuber-ez/master/

(Above diagram shows all the kuberEz components)


## Development

run the frontend
```
nvm install 14.19.0 && nvm use 14.19.0
npm i
npm run serve
```

run the tunneling server
```
git clone ..
cd kubeez-tunneling
mvn spring-boot:run
```

run the gateway
```
cd gateway
mvn spring-boot:run
```

## How to add new component

You can find examples of Kubernetes object models in https://github.com/uengine-oss/kuber-ez/blob/master/src/components/designer/k8s-modeling/element.
Create a new copy of element and property panel component for the K8S object kind (e.g. Deployment.vue and DeploymentPropertyPanel.vue), and place them in the above folder.
Then add the component to the 'elementTypes' array of https://github.com/uengine-oss/kuber-ez/blob/master/src/components/designer/k8s-modeling/KubeModeler.vue file.




## Documentation

https://intro.msaez.io/tool/infrastructure-modeling
Expand Down
45 changes: 45 additions & 0 deletions gateway/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/target/
/bin/
/.settings/
*#
*.iml
*.ipr
*.iws
*.jar
*.sw?
*~
.#*
.*.md.html
.DS_Store
.classpath
.factorypath
.gradle
.idea
.metadata
.project
.recommenders
.settings
.springBeans
/build
/code
MANIFEST.MF
_site/
activemq-data
bin
build
build.log
dependency-reduced-pom.xml
dump.rdb
interpolated*.xml
lib/
manifest.yml
overridedb.*
settings.xml
target
transaction-logs
.flattened-pom.xml
secrets.yml
.gradletasknamecache
.sts4-cache
node_modules
.dist/
6 changes: 6 additions & 0 deletions gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM openjdk:8u212-jdk-alpine
COPY target/*SNAPSHOT.jar app.jar
EXPOSE 8080
ENV TZ=Asia/Seoul
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENTRYPOINT ["java","-Xmx400M","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar","--spring.profiles.active=docker"]
85 changes: 85 additions & 0 deletions gateway/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
steps:
- id: 'build'
name: 'gcr.io/cloud-builders/mvn'
args: [
'clean',
'package',
'-Dmaven.test.skip=true'
]
### Build
- id: 'docker build'
name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args:
- '-c'
- |
echo '$COMMIT_SHA =' $COMMIT_SHA
docker build -t gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA .
### Test
### Publish
- id: 'publish'
name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args:
- '-c'
- |
docker push gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA
### deploy
- id: 'deploy'
name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
PROJECT=$$(gcloud config get-value core/project)
gcloud container clusters get-credentials "$${CLOUDSDK_CONTAINER_CLUSTER}" \
--project "$${PROJECT}" \
--zone "$${CLOUDSDK_COMPUTE_ZONE}"
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
name: $_PROJECT_NAME
labels:
app: $_PROJECT_NAME
spec:
ports:
- port: 8080
targetPort: 8080
selector:
app: $_PROJECT_NAME
type:
LoadBalancer
EOF
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: $_PROJECT_NAME
labels:
app: $_PROJECT_NAME
spec:
replicas: 1
selector:
matchLabels:
app: $_PROJECT_NAME
template:
metadata:
labels:
app: $_PROJECT_NAME
spec:
containers:
- name: $_PROJECT_NAME
image: gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA
ports:
- containerPort: 8080
EOF
substitutions:
_PROJECT_NAME: gateway
options:
env:
# # location/name of GKE cluster (used by all kubectl commands)
- CLOUDSDK_COMPUTE_ZONE=asia-northeast1-a
- CLOUDSDK_CONTAINER_CLUSTER=standard-cluster-1
21 changes: 21 additions & 0 deletions gateway/kubernetes/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: gateway
labels:
app: gateway
spec:
replicas: 1
selector:
matchLabels:
app: gateway
template:
metadata:
labels:
app: gateway
spec:
containers:
- name: gateway
image: username/gateway:latest
ports:
- containerPort: 8080
13 changes: 13 additions & 0 deletions gateway/kubernetes/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: gateway
labels:
app: gateway
spec:
ports:
- port: 8080
targetPort: 8080
selector:
app: gateway
type: LoadBalancer
54 changes: 54 additions & 0 deletions gateway/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>boot-camp-gateway</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>boot-camp-gateway</name>

<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
</properties>

<dependencies>
<!-- Add Stackdriver Trace Starter -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
15 changes: 15 additions & 0 deletions gateway/src/main/java/fisherp/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package fisherp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class Application {

public static ApplicationContext applicationContext;

public static void main(String[] args) {
applicationContext = SpringApplication.run(Application.class, args);
}
}
60 changes: 60 additions & 0 deletions gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
server:
port: 8088

---

spring:
profiles: default
cloud:
gateway:
#<<< API Gateway / Routes
routes:
- id: tunneling
uri: http://localhost:8080
predicates:
- Path=/api/**, /apis/**
- id: frontend
uri: http://localhost:8081
predicates:
- Path=/**
#>>> API Gateway / Routes
globalcors:
corsConfigurations:
'[/**]':
allowedOrigins:
- "*"
allowedMethods:
- "*"
allowedHeaders:
- "*"
allowCredentials: true


---

spring:
profiles: docker
cloud:
gateway:
routes:
- id: tunneling
uri: http://localhost:8080
predicates:
- Path=/api/**, /apis/**
- id: frontend
uri: http://localhost:8081
predicates:
- Path=/**
globalcors:
corsConfigurations:
'[/**]':
allowedOrigins:
- "*"
allowedMethods:
- "*"
allowedHeaders:
- "*"
allowCredentials: true

server:
port: 8080
1 change: 1 addition & 0 deletions kubeez-tunneling
Submodule kubeez-tunneling added at e5dd74
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": false,
"scripts": {
"serve": "vue-cli-service serve --host 0.0.0.0 --disableHostCheck true",
"serve": "vue-cli-service serve --port 8081 --host 0.0.0.0 --disableHostCheck true",
"build": "vue-cli-service build",
"deploy": "gh-pages -d dist"
},
Expand Down

0 comments on commit 9fc7da2

Please sign in to comment.