To use the built-in etcd store from one of the Db2 deployments in your
HADR configuration, you must create a network policy to allow other database deployments to
communicate with the etcd pod.
About this task
Creating a network policy will allow incoming connections to the etcd pod. For more details
on the built-in etcd store, see Setting up an etcd store for HADR in Db2.Important: The
built-in etcd store is not to be used in production environments.
Procedure
-
Create variables referencing the Db2uCluster or Db2uInstance name and namespace being used. Use the corresponding variables for Db2uCluster
or Db2uInstance with the database deployment containing the built-in etcd store
you are using.
export DB2_CR_ID=<db2ucluster_name/db2uinstance_name>
export NAMESPACE=<namespace_of_db2ucluster/namespace_of_db2uinstance>>
- Create a network policy for the etcd pod by modifying, then running the following scripts
for Db2uCluster or Db2uInstance.
cat <<EOF | oc apply -f -
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: c-${DB2_CR_ID}-etcd-ext
namespace: ${NAMESPACE}
spec:
ingress:
- ports:
- port: 2379
protocol: TCP
podSelector:
matchLabels:
formation_id: ${DB2_CR_ID}
component: etcd
policyTypes:
- Ingress
EOF
Results
You can now use the network policy to access etcd for automated failover.