How to solve ‘error: resource mapping not found for name: “kafka-pdb”‘

I was following the instruction of Kafka installation of the book

Building Big Data Pipelines with Apache Beam

but the bellow command failed

git:(main) ./env/install-kafka.sh
Sending build context to Docker daemon   2.56kB
Step 1/7 : FROM openjdk:11
11: Pulling from library/openjdk
001c52e26ad5: Pull complete 
d9d4b9b6e964: Pull complete 
2068746827ec: Pull complete 
9daef329d350: Pull complete 
d85151f15b66: Pull complete 
66223a710990: Pull complete 
db38d58ec8ab: Pull complete 
Digest: sha256:99bac5bf83633e3c7399aed725c8415e7b569b54e03e4599e580fc9cdb7c21ab
Status: Downloaded newer image for openjdk:11
 ---> 47a932d998b7
Step 2/7 : ENV KAFKA_DATA_DIR=/var/lib/kafka/data   KAFKA_HOME=/opt/kafka   PATH=$PATH:/opt/kafka/bin
 ---> Running in bd0cc8e0f983
Removing intermediate container bd0cc8e0f983
 ---> 9c318bf6d88b
Step 3/7 : ARG KAFKA_VERSION=2.5.1
 ---> Running in 1406e5d450e6
Removing intermediate container 1406e5d450e6
 ---> 8fb61ac7a8b7
Step 4/7 : ARG KAFKA_DIST=kafka_2.13-${KAFKA_VERSION}
 ---> Running in c5d68b2854d0
Removing intermediate container c5d68b2854d0
 ---> e48199a3968b
Step 5/7 : RUN wget -q "https://archive.apache.org/dist/kafka/$KAFKA_VERSION/$KAFKA_DIST.tgz"     && tar -xzf "$KAFKA_DIST.tgz" -C /opt     && rm -r $KAFKA_DIST.tgz
 ---> Running in c4d9d7e939e1
Removing intermediate container c4d9d7e939e1
 ---> 43d645e13ba1
Step 6/7 : RUN set -x     && ln -s /opt/$KAFKA_DIST $KAFKA_HOME     && mkdir -p $KAFKA_DATA_DIR     && useradd kafka     && chown kafka:kafka $KAFKA_DATA_DIR     && chown kafka:kafka -R $KAFKA_HOME     && sed -i "s/^log.dirs=.\+/log.dirs=\/var\/lib\/kafka\/data\//" /opt/kafka/config/server.properties
 ---> Running in 739ab945269c
+ ln -s /opt/kafka_2.13-2.5.1 /opt/kafka
+ mkdir -p /var/lib/kafka/data
+ useradd kafka
+ chown kafka:kafka /var/lib/kafka/data
+ chown kafka:kafka -R /opt/kafka
+ sed -i s/^log.dirs=.\+/log.dirs=\/var\/lib\/kafka\/data\// /opt/kafka/config/server.properties
Removing intermediate container 739ab945269c
 ---> 37fe4df6cb4e
Step 7/7 : USER kafka
 ---> Running in 2c78a3fdac71
Removing intermediate container 2c78a3fdac71
 ---> 52811c984633
Successfully built 52811c984633
Successfully tagged kafka-packt:latest
service/zk-hs created
service/zk-cs created
statefulset.apps/zk created
service/kafka created
statefulset.apps/kafka created
error: resource mapping not found for name: "kafka-pdb" namespace: "" from "./env/manifests/kafka_micro.yaml": no matches for kind "PodDisruptionBudget" in version "policy/v1beta1"
ensure CRDs are installed first

The Fix

# replace in ./env/manifests/kafka_micro.yaml
# policy/v1 instead of policy/v1beta1
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: kafka-pdb
spec:
  selector:
    matchLabels:
      app: kafka
  maxUnavailable: 1

https://stackoverflow.com/questions/73094229/poddisruptionbudget-minikube-1-26-0/73107327#73107327

then rerun it

git:(main) \u2717  ./env/install-kafka.sh                        
Sending build context to Docker daemon   2.56kB
Step 1/7 : FROM openjdk:11
 ---> 47a932d998b7
Step 2/7 : ENV KAFKA_DATA_DIR=/var/lib/kafka/data   KAFKA_HOME=/opt/kafka   PATH=$PATH:/opt/kafka/bin
 ---> Using cache
 ---> 9c318bf6d88b
Step 3/7 : ARG KAFKA_VERSION=2.5.1
 ---> Using cache
 ---> 8fb61ac7a8b7
Step 4/7 : ARG KAFKA_DIST=kafka_2.13-${KAFKA_VERSION}
 ---> Using cache
 ---> e48199a3968b
Step 5/7 : RUN wget -q "https://archive.apache.org/dist/kafka/$KAFKA_VERSION/$KAFKA_DIST.tgz"     && tar -xzf "$KAFKA_DIST.tgz" -C /opt     && rm -r $KAFKA_DIST.tgz
 ---> Using cache
 ---> 43d645e13ba1
Step 6/7 : RUN set -x     && ln -s /opt/$KAFKA_DIST $KAFKA_HOME     && mkdir -p $KAFKA_DATA_DIR     && useradd kafka     && chown kafka:kafka $KAFKA_DATA_DIR     && chown kafka:kafka -R $KAFKA_HOME     && sed -i "s/^log.dirs=.\+/log.dirs=\/var\/lib\/kafka\/data\//" /opt/kafka/config/server.properties
 ---> Using cache
 ---> 37fe4df6cb4e
Step 7/7 : USER kafka
 ---> Using cache
 ---> 52811c984633
Successfully built 52811c984633
Successfully tagged kafka-packt:latest
service/zk-hs unchanged
service/zk-cs unchanged
statefulset.apps/zk configured
service/kafka unchanged
poddisruptionbudget.policy/kafka-pdb created
statefulset.apps/kafka configured