Integrate with Kubernetes¶
A simple demo to deploy ServiceCenter Cluster in Kubernetes.
ServiceCenter supports two deploy modes: Platform Registration
and Client Side Registration
Requirements¶
- There is a Kubernetes cluster.
- Already install
kubectl
andhelm client
in your local machine. - (Optional) Already deploy helm tiller on Kubernetes.
Platform Registration¶
The platform registration indicates that the ServiceCenter automatically accesses kubernetes
cluster,
and micro-service instances can discover service and endpoints information through
the ServiceCenter.
Notes: After deployment, it only create ServiceCenter cluster in the default
namespace.
Use Kubectl¶
You can use the command kubectl apply
to deploy ServiceCenter cluster.
cd ${PROJECT_ROOT}/examples/infrastructures/k8s
kubectl apply -f <(helm template --name servicecomb --namespace default service-center/)
Use Helm Install¶
You can also use the helm commands to deploy ServiceCenter cluster if you already deploy helm tiller.
cd ${PROJECT_ROOT}/examples/infrastructures/k8s
helm install --name servicecomb --namespace default service-center/
Client Side Registration¶
The client-side registration representational ServiceCenter receives and
processes registration requests from micro-service instances and
stores instance information in etcd
.
Notes: After deployment, it create ServiceCenter cluster and etcd cluster in the default
namespace.
Use Kubectl¶
You can use the command kubectl apply
to deploy ServiceCenter cluster.
cd ${PROJECT_ROOT}/examples/infrastructures/k8s
# install etcd cluster
kubectl apply -f <(helm template --name coreos --namespace default etcd/)
# install sc cluster
kubectl apply -f <(helm template --name servicecomb --namespace default \
--set sc.discovery.type="etcd" \
--set sc.discovery.clusters="http://coreos-etcd-client:2379" \
--set sc.registry.enabled=true \
--set sc.registry.type="etcd" \
service-center/)
Use Helm Install¶
You can also use the helm commands to deploy ServiceCenter cluster if you already deploy helm tiller.
cd ${PROJECT_ROOT}/examples/infrastructures/k8s
# install etcd cluster
helm install --name coreos --namespace default etcd/
# install sc cluster
helm install --name servicecomb --namespace default \
--set sc.discovery.type="etcd" \
--set sc.discovery.clusters="http://coreos-etcd-client:2379" \
--set sc.registry.enabled=true \
--set sc.registry.type="etcd" \
service-center/
Confirm the deploy is ok¶
By default, the ServiceCenter frontend use NodePort
service type to deploy in Kubernetes.
- You can execute the command
kubectl get pod
, to check all pods are running. - You can also point your browser to
http://${NODE}:30103
to view the dashboard of ServiceCenter. - (Recommended) You can use scctl tool to list micro-service information.
# ./scctl get svc --addr http://servicecomb-service-center:30100 -owide
DOMAIN | NAME | APPID | VERSIONS | ENV | FRAMEWORK | ENDPOINTS | AGE
+---------+-------------------------------------+-------------------------+----------+-----+------------+--------------------------+-----+
default | servicecomb-service-center-frontend | service-center-frontend | 0.0.1 | | Kubernetes | http://172.0.1.101:30103 | 2m
default | servicecomb-service-center | service-center | 0.0.1 | | Kubernetes | http://172.0.1.102:30100 | 2m
Clean up¶
If you use the kubectl to deploy, take deploy mode platform registration
as example.
cd ${PROJECT_ROOT}/examples/infrastructures/k8s
kubectl delete -f <(helm template --name servicecomb --namespace default service-center/)
If you use helm tiller to deploy, take deploy mode platform registration
as example.
cd ${PROJECT_ROOT}/k8s
helm delete --purge servicecomb
Helm Configuration Values¶
- Service Center (sc)
- deployment (bool: true) Deploy this component or not.
- service
type
(string: “ClusterIP”) The kubernetes service type.externalPort
(int16: 30100) The external access port. If the type isClusterIP
, it is set to the access port of the kubernetes service, and if the type isNodePort
, it is set to the listening port of the node.
- discovery
type
(string: “aggregate”) The Service Center discovery type. This can also be set toetcd
orservicecenter
.aggregate
let Service Center merge the discovery sources and applications can discover microservices from these through using Service Center HTTP API.etcd
let Service Center start with client registration mode, all the microservices information comes from application self registration.servicecenter
let Service Center manage multiple Service Center clusters at the same time. It can be applied to multiple datacenters scenarios.aggregate
(string: “k8s,etcd”) The discovery sources of aggregation, only enabled iftype
is set toaggregate
. Different discovery sources are merged together by commas(,), indicating that the Service Center will aggregate service information through these sources. Now support these scenarios:k8s,etcd
(for managing services from multiple platforms),k8s,servicecenter
(for accessing distinct kubernetes clusters).clusters
(string: “sc-0=http://127.0.0.1:2380”) The cluster address managed by Service Center. Iftype
is set toetcd
, its format ishttp(s)://{etcd-1},http(s)://{etcd-2}
. Iftype
is set to other value, its format is{cluster name 1}=http(s)://{cluster-1-1},http(s)://{cluster-1-2},{cluster-2}=http(s)://{cluster-2-1}
- registry
enabled
(bool: false) Register Service Center itself or not.type
(string: “embedded_etcd”) The class of backend storage provider, this decide how Service Center store the microservices information.embedded_etcd
let Service Center store data in local file system, it means distributed file system is need if you deploy high availability Service Center.etcd
let Service Center store data in existing etcd cluster, then Service Center could be a stateless service.builin
disabled the storage.name
(string: “sc-0”) The Service Center cluster name, only enabled iftype
is set toembedded_etcd
oretcd
.addr
(string: “http://127.0.0.1:2380”) The backend storage provider address. This value should be a part ofsc.discovery.clusters
value.
- UI (frontend)
- deployment (bool: true) Deploy this component of not.
- service
type
(string: “NodePort”) The kubernetes service type.externalPort
(int16: 30103) The external access port. If the type isClusterIP
, it is set to the access port of the kubernetes service, and if the type isNodePort
, it is set to the listening port of the node.