Deploying OpenResty Edge in Kubernetes
Before you begin deployment, please ensure you have set up a Kubernetes cluster.
Download Deployment File
First, navigate to the OpenResty Company’s Download Center to download the latest deployment file openresty-edge-VERSION.yml
.
Adjust Deployment File
After downloading the deployment file, please adjust the following configuration according to your specific situation:
Modify the
storageClassName
to match the storage class name in your cluster. It is recommended to use network storage such as NFS or Ceph. The defaultstorageClassName
in the configuration file is set tolocal-path
.For PVCs named
oredge-admin-database
andoredge-log-server-database
, we recommend using a StorageClass withreclaimPolicy: Retain
to prevent accidental deletion of database data.For the volumeClaimTemplates named
oredge-node-data
, the StorageClass used can employ the default policyreclaimPolicy: Delete
.
You may also adjust the following configurations according to your needs (optional):
- The default port for the Edge Admin Web service is set to 30443, with the default type being
NodePort
. - By default, The Edge Node service is exposed externally through the
LoadBalancer
type. - The Persistent Volume Claim (PVC) size for the Edge Admin database, the Edge Log Server database, and the Edge Node. The Edge Admin and Edge Log Server databases are configured for
200GB
by default. For each Edge Node instance, the default is configured for100GB
, which is used to store the Edge Node’s configuration, proxy cache, and logs. If you run 10 Edge Node instances, these Edge Nodes will collectively be allowed to consume up to1000GB
of storage space.
Execute OpenResty Edge Deployment
After making the necessary adjustments to the deployment file, you can use the kubectl
command line tool to deploy OpenResty Edge.
kubectl apply --server-side=true -f openresty-edge-VERSION.yml
The --server-side=true
option is used here because some of the configurations in the deployment file may exceed the limits of the kubectl client mode.
The deployment process will create the following resources:
- A namespace named
openresty-edge
- A secret named
openresty-edge-registry-secret
for pulling OpenResty Edge images - Four ConfigMaps, corresponding to the OpenResty Edge configuration package (openresty-edge-config-package), Edge Admin configuration (oredge-admin-config-ini), Edge Log Server configuration (oredge-log-server-config-ini), and Edge Node configuration (oredge-node-config-ini)
- Four StatefulSets, respectively corresponding to the Edge Admin database (oredge-admin-database), Edge Log Server database (oredge-log-server-database), Edge Admin (oredge-admin), and Edge Node (oredge-node)
- A Deployment for the Edge Log Server (oredge-log-server)
- Five services corresponding to the Edge Admin Database, Edge Admin, Edge Log Server Database, Edge Log Server, and Edge Node
- Two PVCs, respectively, for the Edge Admin database and the Edge Log Server database
- Several PVCs, each for every Edge Node instance
Confirm Deployment Status
After deployment, you can check the status of the pods to confirm whether OpenResty Edge has been deployed correctly.
kubectl get pods -n openresty-edge
Ensure all OpenResty Edge related pods are in the Running
state.
Accessing OpenResty Edge
You can obtain the address information needed to access the Edge Admin Web by looking up the configuration of the services:
kubectl get svc -n openresty-edge
After obtaining the service information related to OpenResty Edge, use the returned external IP address or domain name to access the OpenResty Edge Web interface: https://KUBERNERTES_NODE_IP:30443.
The username to use for login is: admin
;
The password can be extracted from the deployment file:
grep -A 1 'EDGE_ADMIN_INIT_PASSWORD' openresty-edge-VERSION.yml | grep value | awk -F "'" '{print $2}'
With this, the deployment is complete.
Additional Information
When you are using a StorageClass with the default reclaimPolicy: Delete
, we recommend the following actions to avoid data loss due to accidental operations:
Regularly backup the data of OpenResty Edge Admin DB and OpenResty Edge Log Server DB.
Modify the reclaim policy of the PVs for oredge-admin-database and oredge-log-server-database to
Retain
:
kubectl get pv -n openresty-edge | grep -E 'oredge-admin-database|oredge-log-server-database' | awk -F ' ' '{print $1}' | xargs -n1 -I {} kubectl patch pv {} -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}' -n openresty-edge