text stringlengths 0 59.1k |
|---|
The important thing to note here is the `selector`. It is a query over labels, that identifies the set of _Pods_ contained by the _Service_. In this case the selector is `name: hazelcast`. If you look at the Replication Controller specification below, you'll see that the pod has the corresponding label, so it will be... |
Create this service as follows: |
```sh |
$ kubectl create -f examples/storage/hazelcast/hazelcast-service.yaml |
``` |
### Adding replicated nodes |
The real power of Kubernetes and Hazelcast lies in easily building a replicated, resizable Hazelcast cluster. |
In Kubernetes a _[_Deployment_](https://kubernetes.io/docs/user-guide/deployments.md)_ is responsible for replicating sets of identical pods. Like a _Service_ it has a selector query which identifies the members of its set. Unlike a _Service_ it also has a desired number of replicas, and it will create or delete _Pods... |
Deployments will "adopt" existing pods that match their selector query, so let's create a Deployment with a single replica to adopt our existing Hazelcast Pod. |
<!-- BEGIN MUNGE: EXAMPLE hazelcast-controller.yaml --> |
```yaml |
apiVersion: "apps/v1" # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1 |
kind: Deployment |
metadata: |
name: hazelcast |
labels: |
name: hazelcast |
spec: |
selector: |
matchLabels: |
name: hazelcast |
template: |
metadata: |
labels: |
name: hazelcast |
spec: |
containers: |
- name: hazelcast |
image: quay.io/pires/hazelcast-kubernetes:0.8.0 |
imagePullPolicy: Always |
env: |
- name: "DNS_DOMAIN" |
value: "cluster.local" |
ports: |
- name: hazelcast |
containerPort: 5701 |
``` |
[Download example](hazelcast-deployment.yaml?raw=true) |
<!-- END MUNGE: EXAMPLE hazelcast-controller.yaml --> |
You may note that we tell Kubernetes that the container exposes the `hazelcast` port. |
The bulk of the replication controller config is actually identical to the Hazelcast pod declaration above, it simply gives the controller a recipe to use when creating new pods. The other parts are the `selector` which contains the controller's selector query, and the `replicas` parameter which specifies the desired ... |
Last but not least, we set `DNS_DOMAIN` environment variable according to your Kubernetes clusters DNS configuration. |
Create this controller: |
```sh |
$ kubectl create -f examples/storage/hazelcast/hazelcast-deployment.yaml |
``` |
After the controller provisions successfully the pod, you can query the service endpoints: |
```sh |
$ kubectl get endpoints hazelcast -o yaml |
apiVersion: v1 |
kind: Endpoints |
metadata: |
creationTimestamp: 2017-03-15T09:40:11Z |
labels: |
name: hazelcast |
name: hazelcast |
namespace: default |
resourceVersion: "65060" |
selfLink: /api/v1/namespaces/default/endpoints/hazelcast |
uid: 62645b71-0963-11e7-b39c-080027985ce6 |
subsets: |
- addresses: |
- ip: 172.17.0.2 |
nodeName: minikube |
targetRef: |
kind: Pod |
name: hazelcast-4195412960-mgqtk |
namespace: default |
resourceVersion: "65058" |
uid: 7043708f-0963-11e7-b39c-080027985ce6 |
ports: |
- port: 5701 |
protocol: TCP |
``` |
You can see that the _Service_ has found the pod created by the replication controller. |
Now it gets even more interesting. Let's scale our cluster to 2 pods: |
```sh |
$ kubectl scale deployment hazelcast --replicas 2 |
``` |
Now if you list the pods in your cluster, you should see two hazelcast pods: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.