Toggle navigation
Home
安装部署
Archives
Tags
Ignite Kubernetes Deployment
2019-11-13 09:26:30
64
0
0
louyj
An Apache Ignite cluster can be easily deployed in and maintained by Kubernetes which is an open-source system for automating deployment, scaling, and management of containerized applications. First, you need to choose how you would like to use Ignite: - If it will be used in the pure in-memory mode or as a caching layer on top of a 3rd party database (RDBMS, NoSQL) then refer to the Stateless Deployment guide. - If Ignite will be deployed as a memory-centric database with Ignite persistence enabled then refer to the Stateful Deployment documentation. #Prerequisities Makes sure that you've done the following: - Deployed a Kubernetes cluster in the desired environment. - Configured RBAC Authorization - Deployed Ignite Service ##Configured RBAC Authorization It's recommended to set up RBAC for your Ignite deployments to have fine-grained control of your deployments and to avoid any security-related issues. vi rbac.yaml ``` apiVersion: v1 kind: Namespace metadata: name: ignite --- apiVersion: v1 kind: ServiceAccount metadata: name: ignite namespace: ignite --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRole metadata: name: ignite namespace: ignite rules: - apiGroups: - "" resources: # Here are resources you can access - pods - endpoints verbs: # That is what you can do with them - get - list - watch --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1beta1 metadata: name: ignite roleRef: kind: ClusterRole name: ignite apiGroup: rbac.authorization.k8s.io subjects: - kind: ServiceAccount name: ignite namespace: ignite ``` Run this command to create the binding: kubectl create -f rbac.yaml Finally, switch the current namespace to ignite so that you can see all the resources belonging to it: kubectl config set-context $(kubectl config current-context) --namespace=ignite ##Ignite Service Deployment Ignite Service is used for Ignite nodes auto-discovery and as a LoadBalancer for external applications that will be connecting to an Ignite cluster. Ignite's KubernetesIPFinder requires users to configure and deploy a special Kubernetes service that maintains a list of the IP addresses of all the alive Ignite pods (nodes). Every time a new Ignite pod is started, the IP finder will connect to the service via the Kubernetes API to obtain the list of the existing Ignite pods' addresses. Using these addresses, the new node will be able to discover the rest of the cluster nodes and finally join the Apache Ignite cluster. Also, it's possible to reuse the same service as a LoadBalancer for external applications that will be connecting to the Ignite cluster. **ignite-service.yaml** ``` apiVersion: v1 kind: Service metadata: # The name must be equal to TcpDiscoveryKubernetesIpFinder.serviceName name: ignite # The name must be equal to TcpDiscoveryKubernetesIpFinder.namespaceName namespace: ignite spec: type: LoadBalancer ports: - name: rest port: 8080 targetPort: 8080 - name: sql port: 10800 targetPort: 10800 - name: thinclients port: 10900 targetPort: 10900 # Optional - remove 'sessionAffinity' property if the Ignite cluster # and applications deployed within Kubernetes sessionAffinity: ClientIP selector: # Must be equal to the label set for Ignite pods. app: ignite ``` and deploy it in Kubernetes using the command below (ensure that you configured a unique namespace and RBAC for Ignite beforehand): kubectl create -f ignite-service.yaml Make sure the service is up and running: kubectl get svc ignite --namespace=ignite #Stateless Deployment(in-memory mode) If Ignite will be used in the pure in-memory mode or as a caching layer on top of a 3rd party database (RDBMS, NoSQL) then it can be deployed as a stateless solution. ##Kubernetes IP Finder To enable Apache Ignite nodes auto-discovery in Kubernetes, you need to enable TcpDiscoveryKubernetesIpFinder in IgniteConfiguration. **ignite-in-memory.xml** ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> <bean class="org.apache.ignite.configuration.IgniteConfiguration"> <property name="discoverySpi"> <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> <property name="ipFinder" <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder"> <property name="namespace" value="ignite"/> </bean> </property> </bean> </property> </bean> </beans> ``` ##Ignite Pods Deployment **ignite-deployment.yaml** ``` # An example of a Kubernetes configuration for Ignite pods deployment. apiVersion: extensions/v1beta1 kind: Deployment metadata: # Custom Ignite cluster's name. name: ignite-cluster namespace: ignite spec: # A number of Ignite pods to be started by Kubernetes initially. replicas: 2 template: metadata: labels: app: ignite spec: serviceAccountName: ignite containers: # Custom Ignite pod name. - name: ignite-node image: apacheignite/ignite:2.5.0 env: - name: OPTION_LIBS value: ignite-kubernetes - name: CONFIG_URI value: https://raw.githubusercontent.com/apache/ignite/master/modules/kubernetes/config/example-kube-rbac.xml ports: # Ports to open. # Might be optional depending on your Kubernetes environment. - containerPort: 11211 # REST port number. - containerPort: 47100 # communication SPI port number. - containerPort: 47500 # discovery SPI port number. - containerPort: 49112 # JMX port number. - containerPort: 10800 # SQL port number. - containerPort: 10900 # Thin clients port number. ``` As you can see, the configuration defines a couple of environment variables (OPTION_LIBS and CONFIG_URIL) that will be processed by a special shell script used by Ignite's docker image. Next, go ahead and deploy Ignite pods in Kubernetes using the configuration above: kubectl create -f ignite-deployment.yaml ##Adjusting Ignite Cluster Size You can adjust Apache Ignite cluster size on the fly using the standard Kubernetes API. For instance, if you want to scale out the cluster from 2 to 5 nodes then the command below can be used: kubectl scale --replicas=5 -f ignite-deployment.yaml #Stateful Deployment(persistence mode) If Ignite will be deployed as a memory-centric database with Ignite persistence enabled then it needs to be deployed as a stateful solution. see https://apacheignite.readme.io/docs/stateful-deployment
Pre:
istio deployment
Next:
Kubeless Deployment
0
likes
64
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Submit
Sign in
to leave a comment.
No Leanote account?
Sign up now.
0
comments
More...
Table of content
No Leanote account? Sign up now.