commit | ee6eef565e86680f0806382c733d9e46ff5e8e75 | [log] [tgz] |
---|---|---|
author | Xiangkun Yin <ptyin@apache.org> | Tue Jun 04 21:34:25 2024 +0800 |
committer | GitHub <noreply@github.com> | Tue Jun 04 21:34:25 2024 +0800 |
tree | 080ab846d3075c8961aaad2f3c455fcf41e12c05 | |
parent | 38aa1624db51e5849452bdc2db9921eac1491e6e [diff] |
feature: support ConfigMap and Secret by changing env from map to EnvVar (#17)
Associated Projects:
To experience deploying Seata Server using the Operator method, follow these steps:
Clone this repository:
git clone https://github.com/apache/incubator-seata-k8s.git
(Optional) Build and publish the controller image to a private registry:
This step can be skipped, the operator use apache/seata-controller:latest as controller image by default.
IMG=${IMAGE-TO-PUSH} make docker-build docker-push
If you are using minikube for testing, you can skip the above publishing process with the following command:
eval $(minikube docker-env) IMG=${IMAGE-TO-PUSH} make docker-build
Deploy Controller, CRD, RBAC, and other resources to the Kubernetes cluster:
make deploy kubectl get deployment -n seata-k8s-controller-manager # check if exists
You can now deploy your CR to the cluster. An example can be found here seata-server-cluster.yaml:
apiVersion: operator.seata.apache.org/v1alpha1 kind: SeataServer metadata: name: seata-server namespace: default spec: serviceName: seata-server-cluster replicas: 3 image: seataio/seata-server:latest store: resources: requests: storage: 5Gi
For the example above, if everything is correct, the controller will deploy 3 StatefulSet resources and a Headless Service to the cluster. You can access the Seata Server cluster in the cluster through seata-server-0.seata-server-cluster.default.svc
.
For CRD details, you can visit operator.seata.apache.org_seataservers.yaml. Here are some important configurations:
serviceName
: Used to define the name of the Headless Service deployed by the controller. This will affect how you access the server cluster. In the example above, you can access the Seata Server cluster through seata-server-0.seata-server-cluster.default.svc
.
replicas
: Defines the number of Seata Server replicas. Adjusting this field achieves scaling without the need for additional HTTP requests to change the Seata raft cluster list.
image
: Defines the Seata Server image name.
ports
: Three ports need to be set under the ports
property: consolePort
, servicePort
, and raftPort
, with default values of 7091, 8091, and 9091, respectively.
resources
: Used to define container resource requirements.
store.resources
: Used to define mounted storage resource requirements.
env
: Environment variables passed to the container. You can use this field to define Seata Server configuration. For example:
apiVersion: operator.seata.apache.org/v1alpha1 kind: SeataServer metadata: name: seata-server namespace: default spec: image: seataio/seata-server:latest store: resources: requests: storage: 5Gi env: - name: console.user.username value: seata - name: console.user.password valueFrom: secretKeyRef: name: seata key: password --- apiVersion: v1 kind: Secret metadata: name: seata type: Opaque data: password: seata
Due to certain reasons, Seata Docker images currently do not support external container calls. Therefore, the example projects should also be kept in link mode with the Seata image inside the container.
# Start Seata deployment (nacos,seata,mysql) kubectl create -f deploy/seata-deploy.yaml # Start Seata service (nacos,seata,mysql) kubectl create -f deploy/seata-service.yaml # Get a NodePort IP (kubectl get service) # Modify the IP in examples/examples-deploy for DNS addressing # Connect to MySQL and import table structure # Start example deployment (samples-account,samples-storage) kubectl create -f example/example-deploy.yaml # Start example service (samples-account,samples-storage) kubectl create -f example/example-service.yaml # Start order deployment (samples-order) kubectl create -f example/example-deploy.yaml # Start order service (samples-order) kubectl create -f example/example-service.yaml # Start business deployment (samples-dubbo-business-call) kubectl create -f example/business-deploy.yaml # Start business deployment (samples-dubbo-service-call) kubectl create -f example/business-service.yaml
# Account service - Deduct amount curl -H "Content-Type: application/json" -X POST --data "{\"id\":1,\"userId\":\"1\",\"amount\":100}" cluster-ip:8102/account/dec_account # Storage service - Deduct stock curl -H "Content-Type: application/json" -X POST --data "{\"commodityCode\":\"C201901140001\",\"count\":100}" cluster-ip:8100/storage/dec_storage # Order service - Add order and deduct amount curl -H "Content-Type: application/json" -X POST --data "{\"userId\":\"1\",\"commodityCode\":\"C201901140001\",\"orderCount\":10,\"orderAmount\":100}" cluster-ip:8101/order/create_order # Business service - Client Seata version too low curl -H "Content-Type: application/json" -X POST --data "{\"userId\":\"1\",\"commodityCode\":\"C201901140001\",\"count\":10,\"amount\":100}" cluster-ip:8104/business/dubbo/buy