diff --git a/deployments/kubernetes/README.md b/deployments/kubernetes/README.md index 36f076d4..4500a5fc 100644 --- a/deployments/kubernetes/README.md +++ b/deployments/kubernetes/README.md @@ -14,29 +14,27 @@ Create a namespace in the cluster to manage all the resources of Xconf. Edit `na ### Edit config files -- [ALL Files] Replace `$MICRO_REGISTRY_ADDRESS` to your cluser etcd address or your own etcd service address. -- [ALL Files] Check the version of image, change if you want. -- [config-srv.yaml] Replace `$DATABASE_URL` to your own MySQL database url. -- Change other fields if you know what you are doing. +### Create ConfigMap + +``` +kubectl create -f configmaps.yaml +``` ### Create Kubernets resources ``` -kubectl create -f micro.yaml -kubectl create -f config-srv.yaml -kubectl create -f agent-api.yaml -kubectl create -f admin-api.yaml +kubectl create -f gateway.yaml ``` ### Access Admin UI -By default the micro-api will be exposed by LoadBalancer, check service `micro` under namespace `xconf` for detail. +By default the micro-api will be exposed by LoadBalancer, check service `gateway` under namespace `assistant` for detail. -`kubectl describe --namespace xconf service micro` +`kubectl describe --namespace assistant service gateway` You will find the Ingress address and the port. -Use url `http://addr:port/admin/ui/` to access the admin UI. +Use url `http://addr:port/` to access the web. ## 2. Update diff --git a/deployments/kubernetes/configmaps.yaml b/deployments/kubernetes/configmaps.yaml new file mode 100644 index 00000000..55592027 --- /dev/null +++ b/deployments/kubernetes/configmaps.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: xconf-config + namespace: assistant +data: + xconf.url: http://127.0.0.1:8080 diff --git a/deployments/kubernetes/gateway.yaml b/deployments/kubernetes/gateway.yaml new file mode 100644 index 00000000..8a8be93a --- /dev/null +++ b/deployments/kubernetes/gateway.yaml @@ -0,0 +1,49 @@ +kind: Deployment +apiVersion: apps/v1 +metadata: + name: gateway + namespace: assistant +spec: + replicas: 1 + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 1 + maxSurge: 0 + selector: + matchLabels: + app: gateway + template: + metadata: + labels: + app: gateway + spec: + containers: + - name: gateway + image: 'tsundata/gateway:0.0.1' + imagePullPolicy: Always + env: + - name: XCONF_URL + valueFrom: + configMapKeyRef: + name: xconf-config + key: xconf.url + - name: XCONF_CLUSTER + value: dev + - name: XCONF_NAMESPACE + value: gateway + ports: + - containerPort: 5000 +--- +apiVersion: v1 +kind: Service +metadata: + namespace: assistant + name: gateway +spec: + ports: + - port: 5000 + targetPort: 5000 + selector: + app: gateway + type: LoadBalancer diff --git a/deployments/kubernetes/xconf/namespace.yaml b/deployments/kubernetes/namespace.yaml similarity index 57% rename from deployments/kubernetes/xconf/namespace.yaml rename to deployments/kubernetes/namespace.yaml index 2be48c83..9bd7f6f4 100644 --- a/deployments/kubernetes/xconf/namespace.yaml +++ b/deployments/kubernetes/namespace.yaml @@ -1,6 +1,6 @@ apiVersion: v1 kind: Namespace metadata: - name: xconf + name: assistant labels: - name: xconf + name: assistant diff --git a/deployments/kubernetes/xconf/admin-api.yaml b/deployments/kubernetes/xconf/admin-api.yaml deleted file mode 100644 index f35c31aa..00000000 --- a/deployments/kubernetes/xconf/admin-api.yaml +++ /dev/null @@ -1,33 +0,0 @@ -kind: Deployment -apiVersion: apps/v1 -metadata: - name: admin-api - namespace: xconf -spec: - replicas: 2 - strategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 1 - maxSurge: 1 - selector: - matchLabels: - app: admin-api - template: - metadata: - labels: - app: admin-api - spec: - containers: - - name: admin-api - image: 'xuxu123/admin-api:v0.1.3' - imagePullPolicy: Always - env: - - name: MICRO_SERVER_ADDRESS - value: 0.0.0.0:8080 - - name: MICRO_REGISTRY - value: "etcd" - - name: MICRO_REGISTRY_ADDRESS - value: $MICRO_REGISTRY_ADDRESS - ports: - - containerPort: 8080 diff --git a/deployments/kubernetes/xconf/agent-api.yaml b/deployments/kubernetes/xconf/agent-api.yaml deleted file mode 100644 index 38910d51..00000000 --- a/deployments/kubernetes/xconf/agent-api.yaml +++ /dev/null @@ -1,35 +0,0 @@ -kind: Deployment -apiVersion: apps/v1 -metadata: - name: agent-api - namespace: xconf -spec: - replicas: 2 - strategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 1 - maxSurge: 1 - selector: - matchLabels: - app: agent-api - template: - metadata: - labels: - app: agent-api - spec: - containers: - - name: agent-api - image: 'xuxu123/agent-api:v0.1.3' - imagePullPolicy: Always - env: - - name: MICRO_SERVER_ADDRESS - value: 0.0.0.0:8080 - - name: XCONF_CACHE_SIZE - value: "1048576" - - name: MICRO_REGISTRY - value: "etcd" - - name: MICRO_REGISTRY_ADDRESS - value: $MICRO_REGISTRY_ADDRESS - ports: - - containerPort: 8080 diff --git a/deployments/kubernetes/xconf/config-srv.yaml b/deployments/kubernetes/xconf/config-srv.yaml deleted file mode 100644 index 7c42ec7f..00000000 --- a/deployments/kubernetes/xconf/config-srv.yaml +++ /dev/null @@ -1,35 +0,0 @@ -kind: Deployment -apiVersion: apps/v1 -metadata: - name: config-srv - namespace: xconf -spec: - replicas: 2 - strategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 1 - maxSurge: 1 - selector: - matchLabels: - app: config-srv - template: - metadata: - labels: - app: config-srv - spec: - containers: - - name: config-srv - image: 'xuxu123/config-srv:v0.1.3' - imagePullPolicy: Always - env: - - name: MICRO_SERVER_ADDRESS - value: 0.0.0.0:8080 - - name: DATABASE_URL - value: $DATABASE_URL - - name: MICRO_REGISTRY - value: "etcd" - - name: MICRO_REGISTRY_ADDRESS - value: $MICRO_REGISTRY_ADDRESS - ports: - - containerPort: 8080 diff --git a/deployments/kubernetes/xconf/micro.yaml b/deployments/kubernetes/xconf/micro.yaml deleted file mode 100644 index d732031c..00000000 --- a/deployments/kubernetes/xconf/micro.yaml +++ /dev/null @@ -1,44 +0,0 @@ -kind: Deployment -apiVersion: apps/v1 -metadata: - name: micro - namespace: xconf -spec: - replicas: 2 - strategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 1 - maxSurge: 0 - selector: - matchLabels: - app: micro - template: - metadata: - labels: - app: micro - spec: - containers: - - name: micro - image: 'xuxu123/micro:v0.1.3' - imagePullPolicy: Always - env: - - name: MICRO_REGISTRY - value: "etcd" - - name: MICRO_REGISTRY_ADDRESS - value: $MICRO_REGISTRY_ADDRESS - ports: - - containerPort: 8080 ---- -apiVersion: v1 -kind: Service -metadata: - namespace: xconf - name: micro -spec: - ports: - - port: 8080 - targetPort: 8080 - selector: - app: micro - type: LoadBalancer