background

Apache Pulsar provides a way to deploy Pulsar in A Minikube environment. Get started in Kubernetes, but I prefer Using Kind as a K8s test environment. So try deploying Apache Pulsar in a Kind environment.

Kind Environment Preparation

Since Kind only exposes NodePort of Apiserver by default, it is necessary to set several ports to be exposed to Pulsar Proxy, Pulsar Manager and Grafana before Kind starts.

  1. Write the Kind configuration file
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  extraPortMappings:
  - containerPort: 30111
    hostPort: 30111
  - containerPort: 30112
    hostPort: 30112
  - containerPort: 30113
    hostPort: 30113
Copy the code
  1. Create the Kind cluster by using the following command

kind create cluster --name pulsar-on-k8s --config=kind.yaml

  1. Verify that the K8s environment is complete
$kc get nodes NAME STATUS ROLES AGE VERSION Pulsar-on-k8s-Control-plane Ready control-plane,master 50s V1.21.1Copy the code

Install Pulsar Helm Chart

  1. Added the Pulsar Helm warehouse
helm repo add apache https://pulsar.apache.org/charts
helm repo update
Copy the code
  1. Clone Pulsar Helm Chart’s warehouse
git clone https://github.com/apache/pulsar-helm-chart 
cd pulsar-helm-chart
Copy the code
  1. Run the scriptprepare_helm_release.shTo create the password information needed to install Apache Pulsar Helm Chart
./scripts/pulsar/prepare_helm_release.sh -n pulsar-on-k8s -k pulsar-on-k8s -c
Copy the code

Helm installation Pulsar

  1. Run the following command to deploy Pulsar
helm install pulsar apache/pulsar \
    --timeout 10m \
    --set initialize=true \
    --set namespace=pulsar-on-k8s \
    --set volumes.local_storage=false \
    --set affinity.anti_affinity=false
Copy the code
  1. Confirm the running condition, because several services in Charts are defaultLoadBalancer, so it will always be pending.
$ kc get pods -n pulsar-on-k8s NAME READY STATUS RESTARTS AGE pulsar-bookie-0 1/1 Running 0 44h pulsar-bookie-1 1/1 Running 0 44h pulsar-bookie-2 1/1 Running 0 44h pulsar-bookie-3 1/1 Running 0 44h pulsar-bookie-init-jk5dg 0/1 Completed  0 44h pulsar-broker-0 1/1 Running 0 44h pulsar-broker-1 1/1 Running 1 44h pulsar-broker-2 1/1 Running 1 44h pulsar-grafana-99b4976f7-g5ftf 1/1 Running 0 44h pulsar-prometheus-5f5fb9978b-z272t 1/1 Running 0 44h pulsar-proxy-0 1/1  Running 0 44h pulsar-proxy-1 1/1 Running 0 44h pulsar-proxy-2 1/1 Running 0 44h pulsar-pulsar-init-gmw9m 0/1 Completed 0 44h pulsar-pulsar-manager-76c5cfb97f-ljl7p 1/1 Running 0 44h pulsar-recovery-0 1/1 Running 0 44h pulsar-toolset-0 1/1 Running 0 44h pulsar-zookeeper-0 1/1 Running 0 44h pulsar-zookeeper-1 1/1 Running 0 37h pulsar-zookeeper-2 1/1 Running 0  37hCopy the code
$ kc get svc -n pulsar-on-k8s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE pulsar-bookie ClusterIP None <none> 3181/TCP,8000/TCP 44h pulsar-broker ClusterIP None <none> 8080/TCP,6650/TCP 44h pulsar-grafana LoadBalancer 10.96.179.187 <pending> 300:31615 /TCP 44h pulsar-Prometheus ClusterIP None < None > 9090/TCP 44h pulsar-proxy LoadBalancer 10.96.149.23 < pending > / TCP 80-30436, 6650:31691 / TCP 44 h pulsar - pulsar - manager LoadBalancer 10.96.190.13 <pending> 9527:30807/TCP 44h pulsar-recovery ClusterIP None <none> 8000/TCP 44h pulsar-toolset ClusterIP None <none> <none> 44h pulsar-zookeeper ClusterIP None <none> 2888/TCP,3888/TCP,2181/TCP 44hCopy the code
  1. Modify theLoadBalancerThe service forNodePortAnd set the ports to the ones Kind exposes
$kc Edit SVC pulsar-proxy-n pulsar-on-k8s spec: clusterIP: 10.96.149.23 clusterIPs: -10.96.149.23 externalTrafficPolicy: Cluster ipFamilies: - IPv4 ipFamilyPolicy: SingleStack ports: - name: externalTrafficPolicy: Cluster ipFamilies: - IPv4 ipFamilyPolicy: SingleStack ports: - name: http nodePort: 30436 port: 80 protocol: TCP targetPort: 80 - name: pulsar nodePort: 30111 port: 6650 protocol: TCP targetPort: 6650 selector: app: pulsar component: proxy release: pulsar sessionAffinity: None type: NodePortCopy the code
$KC Edit SVC pulsar-grafana-n pulsar-on-k8s spec: clusterIP: 10.96.179.187 clusterIPs: -10.96.179.187 externalTrafficPolicy: Cluster ipFamilies: - IPv4 ipFamilyPolicy: SingleStack ports: - name: externalTrafficPolicy: Cluster ipFamilies: - IPv4 ipFamilyPolicy: SingleStack ports: - name: server nodePort: 30112 port: 3000 protocol: TCP targetPort: 3000 selector: app: pulsar component: grafana release: pulsar sessionAffinity: None type: NodePortCopy the code
$kc Edit SVC pulsar-pulsar-manager-n pulsar-on-k8s spec: clusterIP: 10.96.190.13 clusterIPs: -10.96.190.13 externalTrafficPolicy: Cluster ipFamilies: - IPv4 ipFamilyPolicy: SingleStack ports: - name: externalTrafficPolicy: Cluster ipFamilies: - IPv4 ipFamilyPolicy: SingleStack ports: - name: server nodePort: 30113 port: 9527 protocol: TCP targetPort: 9527 selector: app: pulsar component: pulsar-manager release: pulsar sessionAffinity: None type: NodePortCopy the code
$ kc get svc -n pulsar-on-k8s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE pulsar-bookie ClusterIP None <none> 3181/TCP,8000/TCP 44h pulsar-broker ClusterIP None < None > 8080/TCP,6650/TCP 44h pulsar-grafana NodePort 10.96.179.187 <none> 300:30112 /TCP 44h pulsar-prometheus ClusterIP None <none> 9090/TCP 44h pulsar-proxy NodePort 10.96.149.23 <none> 80:30436 / TCP, 6650:30111 / TCP 44 h pulsar - pulsar - manager NodePort 10.96.190.13 < none > 9527:30113 / TCP 44 h pulsar - recovery ClusterIP None <none> 8000/TCP 44h pulsar-toolset ClusterIP None <none> <none> 44h pulsar-zookeeper ClusterIP None <none> 2888/TCP,3888/TCP,2181/TCP 44hCopy the code
  1. The Pulsar cluster is now accessed through the ports exposed by Kind.