diff --git a/docs/guides/clustering-and-scaling/kubernetes/deploy-ams-on-kubernetes.md b/docs/guides/clustering-and-scaling/kubernetes/deploy-ams-on-kubernetes.md index 381c492a..31aa8cda 100644 --- a/docs/guides/clustering-and-scaling/kubernetes/deploy-ams-on-kubernetes.md +++ b/docs/guides/clustering-and-scaling/kubernetes/deploy-ams-on-kubernetes.md @@ -1,5 +1,5 @@ --- -title: Deploy Ant Media Server on Kubernetes +title: Manual Deployment description: Deploy Ant Media Server on Kubernetes keywords: [Deploy Ant Media Server on Kubernetes, Kubernetes, Ant Media Server Documentation, Ant Media Server Tutorials] sidebar_position: 2 @@ -7,443 +7,582 @@ sidebar_position: 2 # Deploy Ant Media Server on Kubernetes -Sample AMS Deployment File --------------------------- +This guide explains how to manually deploy an auto-scaling Kubernetes environment. -AMS has such a deployment file structure. This file has a few differences according to the deployment type. Here we will introduce the general file structure. +:::info +You will need to have the [Kubernetes command line tool](https://kubernetes.io/docs/tasks/tools/) and [Helm](https://helm.sh/docs/intro/install/) that package manager for Kubernetes installed on your computer. +::: - kind: Service - apiVersion: v1 - metadata: - name: ant-media-server - spec: - selector: - app: ant-media - ports: - - name: http - protocol: TCP - port: 5080 - --- - apiVersion: apps/v1 - kind: Deployment - metadata: - name: ant-media-server - spec: - selector: - matchLabels: - app: ant-media - replicas: 1 - template: - metadata: - labels: - app: ant-media - spec: - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - ant-media - topologyKey: "kubernetes.io/hostname" - hostNetwork: true - dnsPolicy: ClusterFirstWithHostNet - containers: - - name: ant-media-server - imagePullPolicy: IfNotPresent # change this value accordingly. It can be Never, Always or IfNotPresent - image: ant-media-server-enterprise-k8s:test #change this value according to your image. - # By default, mongodb deployment is used. If you're using mongodb somewhere else, specify it with server url(-h) below. - # You may also need to add -u and -p parameters for - # specifying mongodb username and passwords respectively - args: ["-g", "true", "-s", "true", "-r", "true", "-m", "cluster", "-h", "mongo"] - resources: - requests: - cpu: 4000m - -Here are the explanations for the common parameters and the changes parameters. +## Origin & Edge configurations -### **Common Parameters** +We strongly recommend separate origin and edge instances in Ant Media Cluster. So we have two sets of deployment files for origins and edges.  - -**The following parameters are common parameters independent of deployment type.**   +While publishing a stream, you should use the URL of the load balancer of origins. ```ORIGIN_LOAD_BALANCER_URL/WebRTCAppEE``` -* **imagePullPolicy:** IfNotPresent means that if the image is available in local environment. It'll not be pulled from the private or public registry. -* **image:** ant-media-server-enterprise-k8s:test specifies the name of the image. You should pay attention here as it should be the same name with the image you built in previous step. -* **args:**\["-g", "true", "-s", "true", "-r", "true", "-m", "cluster", "-h", "127.0.0.1"\] specifies the parameters for running the Ant Media Server pods. Let us tell their meanings and why we need them. - * "**\-g**", "true": It means that Ant Media Server uses the public IP address of the host for internal cluster communication. Default value is false. - * "**\-s**", "true": It makes Ant Media Server uses its public IP address as the server name. - * "**\-r**", "true": It makes Ant Media Server replaces the local IP address in the ICE candidates with the server name. It's false by default. - * "**\-m**", "cluster": It specifies the server mode. It can be cluster or standalone. Its default value is standalone. If you're running Ant Media Server in Kubernetes, it's most likely you're running the Ant Media Server in cluster mode. This means you need to specify your MongoDB host, username, and password as parameter. - * "**\-h**", "127.0.0.1": It specifies the MongoDB host address. It's necessary to use if you're running in cluster mode. In this example, it's 127.0.0.1 because in the CI pipeline, local MongoDB is installed. You should change it with your own MongoDB address or replica set. - * "**\-u**", "username": It specifies the username to connect to MongoDB. If you don't have credentials, you don't need to specify. - * "**\-p**", "password": It specifies the password to connect to MongoDB. If you don't have credentials, you don't need to specify. - * "-l", "license number": It makes Ant Media Server uses the license key. +Similarly, you should use the URL of the load balancer of edges in playing. ```EDGE_LOAD_BALANCER_URL/WebRTCAppEE/player.html``` -### **Changing Parameters** +## Horizontal Pod Autoscaling -**The following parameters are different according to the deployment type.** +Kubernetes lets you scale the pods automatically to optimize resource usage and make the backend ready according to the load in your service. Horizontal Pod Autoscaler which is a built-in component can scale your pods automatically. -* **hostNetwork:** true line above means that Ant Media Server uses the host network. It is required as there is a wide range of UDP and TCP ports are being used for WebRTC streaming. This also means that you can only use one pod of Ant Media Server in a host instance. Don't worry about where and how to deploy as K8s handles that. We're just letting you know this to determine total number of nodes in your cluster. -* **affinity: TODO** -* **labels:** for origin edge distinction TODO +Firstly, we need to have a Metrics Server to collect the metrics of the pods. To provide metric via the Metrics API, metric server monitoring must be deployed on the cluster. Horizontal Pod Autoscaler uses this API to collect metrics. -#### Origin & Edge configurations +### Install Metric Server -We strongly recommend separate origin and edge instances in Ant Media Cluster. So we have two sets of deployment files for origins and edges.  +Metric Server is usually deployed by the cloud provider. If you are using a custom Kubernetes cluster or the Metric Server is not deployed by your cloud provider you should deploy it manually as explained below. -While publishing a stream, you should use the URL of the load balancer of origins. ```ORIGIN_LOAD_BALANCER_URL/WebRTCAppEE``` +To check if a metrics-server is installed, use the following command. -Similarly, you should use the URL of the load balancer of edges in playing. ```EDGE_LOAD_BALANCER_URL/WebRTCAppEE/player.html``` +```shell +kubectl get pods --all-namespaces | grep -i "metric" +``` -Kubernetes lets you scale the pods automatically to optimize resource usage and make the backend ready according to the load in your service. Horizontal Pod Autoscaler which is a built-in component can scale your pods automatically. +If the metric server exists, then you should see an output exactly like the below. -Firstly, we need to have a Metrics Server to collect the metrics of the pods. To provide metrics via the Metrics API, a metric server monitoring must be deployed on the cluster. Horizontal Pod Autoscaler uses this API to collect metrics. +```shell +kube-system metrics-server-5bb577dbd8-7f58c 1/1 Running 7 23h +``` -Create horizontal pod autoscaling -================================= +If there is no output as above, proceed to install the metric server manually. -First, make a small change in our yaml file in Ant Media Server by running```kubectl edit deployment ant-media-server-origin and kubectl edit deployment ant-media-server-edge``` . Edit and save the following lines under the container according to yourself. Before proceeding let us tell you about Millicores. Millicores is a metric which is used to measure CPU usage. It is a CPU core divided into 1000 units (milli = 1000). 1000 = 1 core. So the below configuration uses 4 cores. +#### Step 1: Download the components.yaml file on the master - resources: - requests: - cpu: 4000m +```shell +wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml +``` - +#### Step 2: Modify the components.yaml file -After adding the file content should be like as follows: +Add the following to line 132 of the file: `--kubelet-insecure-tls`. - kind: Service - apiVersion: v1 - metadata: - name: ant-media-server - spec: - selector: - app: ant-media - ports: - - name: http - protocol: TCP - port: 5080 - --- - apiVersion: apps/v1 - kind: Deployment - metadata: - name: ant-media-server - spec: - selector: - matchLabels: - app: ant-media - replicas: 1 - template: - metadata: - labels: - app: ant-media - spec: - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - ant-media - topologyKey: "kubernetes.io/hostname" - hostNetwork: true - dnsPolicy: ClusterFirstWithHostNet - containers: - - name: ant-media-server - imagePullPolicy: IfNotPresent # change this value accordingly. It can be Never, Always or IfNotPresent - image: ant-media-server-enterprise-k8s:test #change this value according to your image. - # By default, mongodb deployment is used. If you're using mongodb somewhere else, specify it with server url(-h) below. - # You may also need to add -u and -p parameters for - # specifying mongodb username and passwords respectively - args: ["-g", "true", "-s", "true", "-r", "true", "-m", "cluster", "-h", "mongo"] - resources: - requests: - cpu: 4000m +```yml +spec: + containers: + - args: + - --kubelet-insecure-tls + - --cert-dir=/tmp + - --secure-port=4443 + - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname + - --kubelet-use-node-status-port + image: k8s.gcr.io/metrics-server/metrics-server:v0.4.2 +``` -Check the accuracy of the value we entered using the command below. - +#### Step 3: Deploy the Components.yaml file - kubectl describe deployment/ant-media-server-origin - - kubectl describe deployment/ant-media-server-edge +```shell +kubectl apply -f components.yaml +``` -Now that the deployment is running, we're going to create a Horizontal Pod Autoscaler for it: - +#### Step 4: Verify Successful Deployment - kubectl autoscale deployment ant-media-server-origin --cpu-percent=60 --min=1 --max=10 - - kubectl autoscale deployment ant-media-server-edge --cpu-percent=60 --min=1 --max=10 +Check whether everything is working properly by running the following command: -or you can use the following YAML file: - +```shell +kubectl get apiservices |grep "v1beta1.metrics.k8s.io" +``` +The expected output of the command should be as follows. - kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-hpa-origin.yaml - - kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-hpa-edge.yaml +```shell +v1beta1.metrics.k8s.io kube-system/metrics-server True 21h +``` -In the above configuration, we set the CPU average as 60% and we set the pods as min 1 and maximum 10. A new pod will be created every time the CPU average passes 60%. -You can monitor the situation in the following output. - +### Configure Autoscaling - root@k8s-master:~# kubectl get hpa - NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE - ant-media-server Deployment/ant-media-server 3%/60% 1 10 1 20h +Make a small changes in the yaml files for edge and origin configurations in Ant Media Server: -New pods are going to be created when we start loading and the cpu exceeds 60%. When the cpu average value decreases below 60%, then the pods are going to be terminated. - +:::tip +A [sample deployment file](#sample-deployment-file) is at the end of this guide with detailed explanation of the parametres +::: - root@k8s-master:~# kubectl get hpa - NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE - ant-media-server Deployment/ant-media-server 52%/60% 1 10 4 20h +```shell +kubectl edit deployment ant-media-server-origin +kubectl edit deployment ant-media-server-edge +``` -Check the number of pods running using the following command. - +It's necessary to configure the required CPU cores for our edge and origin by editing the following lines. The value is measured in Millicores. - root@k8s-master:~# kubectl get pods - NAME READY STATUS RESTARTS AGE - ant-media-server-7b9c6844b9-4dtwj 1/1 Running 0 42m - ant-media-server-7b9c6844b9-7b8hp 1/1 Running 0 19h - ant-media-server-7b9c6844b9-9rrwf 1/1 Running 0 18m - ant-media-server-7b9c6844b9-tdxhl 1/1 Running 0 47m - mongodb-9b99f5c-x8j5x 1/1 Running 0 20h +Millicores is a metric which is used to measure CPU usage. It is a CPU core divided into 1000 units (milli = 1000). 1000 = 1 core. So the below configuration defines 4 cores (4000 milliocores). +```yml +resources: + requests: + cpu: 4000m +``` +After adding the content, the file should be as follows: + +```yml +kind: Service +apiVersion: v1 +metadata: + name: ant-media-server +spec: + selector: + app: ant-media + ports: + - name: http + protocol: TCP + port: 5080 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ant-media-server +spec: + selector: + matchLabels: + app: ant-media + replicas: 1 + template: + metadata: + labels: + app: ant-media + spec: + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app + operator: In + values: + - ant-media + topologyKey: "kubernetes.io/hostname" + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + containers: + - name: ant-media-server + imagePullPolicy: IfNotPresent # change this value accordingly. It can be Never, Always or IfNotPresent + image: ant-media-server-enterprise-k8s:test #change this value according to your image. +# By default, mongodb deployment is used. If you're using mongodb somewhere else, specify it with server url(-h) below. +# You may also need to add -u and -p parameters for +# specifying mongodb username and passwords respectively + args: ["-g", "true", "-s", "true", "-r", "true", "-m", "cluster", "-h", "mongo"] + resources: + requests: + cpu: 4000m +``` -  [](https://github.com/ant-media/Ant-Media-Server/wiki/Kubernetes-Autoscaling#utilities)Utilities --------------------------------------------------------------------------------------------------- - -The following command gives information about AutoScale: +Check the accuracy of the value we entered using the command below. +```shell +kubectl describe deployment/ant-media-server-origin +kubectl describe deployment/ant-media-server-edge +``` - kubectl get hpa - +Now that the deployment is running, we're going to create a Horizontal Pod Autoscaler: +```shell +kubectl autoscale deployment ant-media-server-origin --cpu-percent=60 --min=1 --max=10 +kubectl autoscale deployment ant-media-server-edge --cpu-percent=60 --min=1 --max=10 +``` -Check the load of pods running using the command below: +alternatively, you can use the following deployment files: +```shell +#origin +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-hpa-origin.yaml - kubectl top nodes +#edge +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-hpa-edge.yaml +``` +In the above configuration, the CPU resource usage is set to 60%, a minimum pod of 1 and a maximum pod of 10. It means, that whenever the CPU average resource usage exceeds 60%, a new pod will be created to a maximum of 10 pods. + +You can monitor the situation in the following output. + +```shell +root@k8s-master:~$ kubectl get hpa +NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE +ant-media-server Deployment/ant-media-server 3%/60% 1 10 1 20h +``` + +When the cpu average value decreases below 60%, then the pods are going to be terminated. +```shell +root@k8s-master:~$ kubectl get hpa +NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE +ant-media-server Deployment/ant-media-server 52%/60% 1 10 4 20h +``` +Check the number of pods running using the following command. + +```shell +root@k8s-master:~$ kubectl get pods +NAME READY STATUS RESTARTS AGE +ant-media-server-7b9c6844b9-4dtwj 1/1 Running 0 42m +ant-media-server-7b9c6844b9-7b8hp 1/1 Running 0 19h +ant-media-server-7b9c6844b9-9rrwf 1/1 Running 0 18m +ant-media-server-7b9c6844b9-tdxhl 1/1 Running 0 47m +mongodb-9b99f5c-x8j5x 1/1 Running 0 20h +``` +### Useful Commands + +The following command provides information about AutoScale configuration: + +```shell +kubectl get hpa +``` + +Check the load of pods running the following command: + +```shell +kubectl top nodes +``` + This command prints out the following: - root@k8s-master:~# kubectl top node - NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% - k8s-node 111m 5% 717Mi 38% - k8s-node-2 114m 5% 1265Mi 68% - k8s-node-3 98m 4% 663Mi 35% - k8s-node-4 102m 5% 666Mi 35% - n8s-master 236m 11% 1091Mi 58% +```shell +root@k8s-master:~$ kubectl top node +NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% +k8s-node 111m 5% 717Mi 38% +k8s-node-2 114m 5% 1265Mi 68% +k8s-node-3 98m 4% 663Mi 35% +k8s-node-4 102m 5% 666Mi 35% +n8s-master 236m 11% 1091Mi 58% +``` +## Kubernetes Ingress -### Kubernetes Ingress +We are going to use Nginx as an Ingress Controller and install it via Helm. An Ingress Controller is a component in the Kubernetes cluster that configures an HTTP load balancer according to Ingress resources that have been created. -We are going to use Nginx as Ingress and install it via Helm. +Helm is a tool that automates the creation, packaging, configuration, and deployment of Kubernetes applications by combining configuration files into a single reusable package. -### Install HELM +There is already a Nginx Ingress Controller package ready to use, so we can fetch and deploy it via Helm to make life easier. -Run the following commands to install helm. +Run the following commands to install helm and Nginx as Ingress. - - wget -qO- https://get.helm.sh/helm-v3.5.2-linux-amd64.tar.gz | tar zxvf - - cd linux-amd64/ - ./helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx - ./helm repo update - ./helm install ingress-nginx ingress-nginx/ingress-nginx +```shell +wget -qO- https://get.helm.sh/helm-v3.5.2-linux-amd64.tar.gz | tar zxvf - +cd linux-amd64/ +./helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx +./helm repo update +./helm install ingress-nginx ingress-nginx/ingress-nginx +``` Or you can install it via the APT tool. - - curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg >` /dev/null - sudo apt-get install apt-transport-https --yes - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list - sudo apt-get update - sudo apt-get install helm +```shell +curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg >` /dev/null +sudo apt-get install apt-transport-https --yes +echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list +sudo apt-get update +sudo apt-get install helm +``` Make sure everything is working correctly with the following command. -```kubectl get pods -n default | grep "ingress"``` - -### +```shell +kubectl get pods -n default | grep "ingress" +``` -  [](https://github.com/ant-media/Ant-Media-Server/wiki/Kubernetes-Ingress#to-install-an-ssl-certificate)To deploy Ant Media Server with hostNetwork ----------------------------------------------------------------------------------------------------------------------------------------------------- +## Deploy with HostNetwork Run the following commands with hostNetwork -* ```kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-mongodb.yaml``` -* kubectl create -f [https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-deployment-edge.yaml](https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-deployment-edge.yaml) - kubectl create -f [https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-deployment-origin.yaml](https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-deployment-edge.yaml) -* ```kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-hpa-origin.yaml``` - ```kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-hpa-edge.yaml``` -* ```kubectl create -f [https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-ingress-origin.yaml](https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-ingress-origin.yaml)``` - kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-ingress-edge.yaml -* ```kubectl create -f [https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-rtmp.yaml](https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-rtmp.yaml)``` +```shell +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-mongodb.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-deployment-edge.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-deployment-origin.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-hpa-origin.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-hpa-edge.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-ingress-origin.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-ingress-edge.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-rtmp.yaml +``` - [](https://github.com/ant-media/Ant-Media-Server/wiki/Kubernetes-Ingress#to-install-an-ssl-certificate)To deploy Ant Media Server without hostNetwork ------------------------------------------------------------------------------------------------------------------------------------------------------- +## Deploy without HostNetwork Run the following commands without hostNetwork -* ```kubectl create -f [https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-mongodb.yaml](https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-mongodb.yaml)``` -* kubectl create -f [https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-coturn.yaml](https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-coturn.yaml) -* kubectl create -f [https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-deployment-edge.yaml](https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-deployment-edge.yaml) - kubectl create -f [https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-deployment-origin.yaml](https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-deployment-origin.yaml) -* [https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-hpa-origin.yaml](https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-hpa-origin.yaml) - [kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-hpa-edge.yaml](https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-hpa-edge.yaml) -* ```kubectl create -f [https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-ingress-edge.yaml](https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-ingress-edge.yaml)```  - ```kubectl create -f [https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-ingress-origin.yaml](https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-ingress-origin.yaml)``` -* ```kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-rtmp.yaml``` - -  [](https://github.com/ant-media/Ant-Media-Server/wiki/Kubernetes-Ingress#to-install-an-ssl-certificate)To install an SSL certificate --------------------------------------------------------------------------------------------------------------------------------------- +```shell +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-mongodb.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-coturn.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-deployment-edge.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-deployment-origin.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-hpa-origin.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-hpa-edge.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-ingress-edge.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/babf478b99c7e6b15edbd5aa220fde5ba4cd3adb/kubernetes/ams-with-turn-server/ams-k8s-ingress-origin.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-rtmp.yaml +``` +## Install an SSL Certificate + +### Custom certificate If you have your own certificate, you can add it as follows. If you are going to use Let's Encrypt, you can proceed to the next step. -1. ```kubectl create secret tls ${CERT_NAME} --key ${KEY_FILE} --cert ${CERT_FILE}``` -2. ```kubectl create secret tls antmedia-cert --key="ams.key" --cert="ams.crt"``` +```shell +kubectl create secret tls ${CERT_NAME} --key ${KEY_FILE} --cert ${CERT_FILE} +kubectl create secret tls antmedia-cert --key="ams.key" --cert="ams.crt" +``` -If everything is fine, the output of **kubectl get ingress** will be as follows. So the ADRESS column must have appeared a Public IP address. +If everything is fine, the output of **kubectl get ingress** will be as follows. So the ADDRESS column is a Public IP address. - root@kubectl:~# kubectl get ingress - NAME CLASS HOSTS ADDRESS PORTS AGE - ant-media-server `` test.antmedia.io 146.59.2.42 80, 443 94m +```shell +root@kubectl:~# kubectl get ingress +NAME CLASS HOSTS ADDRESS PORTS AGE +ant-media-server `` test.antmedia.io 146.59.2.42 80, 443 94m +``` -### Kubernetes Let's Encrypt Configuration - -**Let's Encrypt Configuration** +### Let's Encrypt Configuration For this, install Helm and Cert-Manager by following the steps below. -**1.** Begin by adding the Jetstack repository to your Helm installation then update the repo. +#### Step 1 - helm repo add jetstack https://charts.jetstack.io - helm repo update +Begin by adding the Jetstack repository to your Helm installation then update the repo. -**2.** Install in your Cert-Manager cluster by running the following line - +```shell +helm repo add jetstack https://charts.jetstack.io +helm repo update +``` - helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --version v1.9.1 --set installCRDs=true +#### Step 2 +Install in your Cert-Manager cluster by running the following line + +```shell +helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --version v1.9.1 --set installCRDs=true +``` -**3.** Install the CustomResourceDefinition resources by using the following command. +#### Step 3 +Install the CustomResourceDefinition resources by using the following command. +```shell +kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.9.1/cert-manager.crds.yaml +``` + +#### Step 4 +Create a YAML file in your working directory and name it **ams-k8s-issuer-production.yaml** Add the following content: + +```yml +apiVersion: cert-manager.io/v1 +kind: ClusterIssuer +metadata: + name: letsencrypt-production +spec: + acme: + server: https://acme-v02.api.letsencrypt.org/directory + email: change_me + privateKeySecretRef: + name: letsencrypt-production + solvers: + - http01: + ingress: + class: nginx +``` - kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.9.1/cert-manager.crds.yaml +Or you can [download](https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-issuer-production.yaml) it from the GitHub repository. -**4.** Create a YAML file in your working directory and name it **ams-k8s-issuer-production.yaml** Add the following content: +:::tip +Provide a valid email address. You will receive email notifications on certificate renewals or alerts. +::: - apiVersion: cert-manager.io/v1 - kind: ClusterIssuer - metadata: - name: letsencrypt-production - spec: - acme: - server: https://acme-v02.api.letsencrypt.org/directory - email: change_me - privateKeySecretRef: - name: letsencrypt-production - solvers: - - http01: - ingress: - class: nginx +Let's deploy the YAML file that we created. -Or you can [download](https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-issuer-production.yaml) it from the GitHub repository. -**Note:** Provide a valid email address. You will receive email notifications on certificate renewals or alerts. - +```shell +kubectl create -f ams-production-issuer.yaml +``` + +When you run the `kubectl get clusterissuers` command, you will see an output like the one below. + +```shell +NAME READY AGE +letsencrypt-production True 27m +``` + +#### Step 5 +We use the `antmedia-cert-edge` and `antmedia-cert-origin` secrets by default for the Origin and Edge sides, and we delete them because there are self-signed certificates. + +```shell +kubectl delete -n antmedia secret antmedia-cert-edge kubectl delete -n antmedia secret antmedia-cert-origin +``` + +#### Step 6 +You must add an annotation **cert-manager.io/cluster-issuer: letsencrypt-production**" in the ingress configuration with the issuer or cluster issuer name. + +```shell +kubectl annotate ingress cert-manager.io/cluster-issuer=letsencrypt-production --all +``` + +If everything went well, the output of the **kubectl get -n antmedia certificate** command will show the value True** as follows. - kubectl create -f ams-production-issuer.yaml +```shell +NAME READY SECRET AGEantmedia-cert-origin True antmedia-cert-origin 21mantmedia-cert-edge True antmedia-cert-edge 24m +``` -When you run the **kubectl get clusterissuers** command, you will see an output like the one below. - NAME READY AGE - letsencrypt-production True 27m -**5.** You must add an annotation "**cert-manager.io/cluster-issuer: letsencrypt-production**" in the ingress configuration with the issuer or cluster issuer name. **YAML file for Origin** - apiVersion: networking.k8s.io/v1 - kind: Ingress - metadata: - name: ant-media-server-origin - annotations: - kubernetes.io/ingress.class: nginx - cert-manager.io/cluster-issuer: letsencrypt-production - nginx.ingress.kubernetes.io/affinity: "cookie" - nginx.ingress.kubernetes.io/session-cookie-name: "route" - nginx.ingress.kubernetes.io/session-cookie-expires: "172800" - nginx.ingress.kubernetes.io/session-cookie-max-age: "172800" - spec: - rules: - - host: origin.antmedia.cloud - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: ant-media-server-origin - port: - number: 5080 - - tls: - - hosts: - - origin.antmedia.cloud - secretName: ams-certificate-origin - -YAML file for Edge - - apiVersion: networking.k8s.io/v1 - kind: Ingress +```yml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: +name: ant-media-server-origin +annotations: + kubernetes.io/ingress.class: nginx + cert-manager.io/cluster-issuer: letsencrypt-production + nginx.ingress.kubernetes.io/affinity: "cookie" + nginx.ingress.kubernetes.io/session-cookie-name: "route" + nginx.ingress.kubernetes.io/session-cookie-expires: "172800" + nginx.ingress.kubernetes.io/session-cookie-max-age: "172800" +spec: +rules: +- host: origin.antmedia.cloud + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: ant-media-server-origin + port: + number: 5080 + +tls: + - hosts: + - origin.antmedia.cloud + secretName: ams-certificate-origin +``` + +**YAML file for Edge** + +```yml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: +name: ant-media-server-edge +annotations: + kubernetes.io/ingress.class: nginx + cert-manager.io/cluster-issuer: letsencrypt-production + nginx.ingress.kubernetes.io/affinity: "cookie" + nginx.ingress.kubernetes.io/session-cookie-name: "route" + nginx.ingress.kubernetes.io/session-cookie-expires: "172800" + nginx.ingress.kubernetes.io/session-cookie-max-age: "172800" +spec: +rules: +- host: edge.antmedia.cloud + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: ant-media-server-edge + port: + number: 5080 + +tls: + - hosts: + - edge.antmedia.cloud + secretName: ams-certificate-edge +``` +#### Step 6 +After creating Ingress you should have tls secret in `kubectl get secret` output. + +```shell +NAME TYPE DATA AGE +ams-certificate-origin kubernetes.io/tls 2 44m +ams-certificate-edge kubernetes.io/tls 2 44m +default-token-72fnb kubernetes.io/service-account-token 3 78m +ingress-nginx-admission Opaque 3 60m +ingress-nginx-token-ncck2 kubernetes.io/service-account-token 3 60m +sh.helm.release.v1.ingress-nginx.v1 helm.sh/release.v1 1 60m +``` +#### Step 7 +Get the Load Balancer IP address with the `kubectl get ingress` command and add it to your DNS server. + +```shell +NAME CLASS HOSTS ADDRESS PORTS AGE +ant-media-server-origin `` origin.antmedia.cloud xxx.xxx.xxx.xxx 80, 443 26m +ant-media-server-edge `` edge.antmedia.cloud xxx.xxx.xxx.xxx 80, 443 26m +``` +#### Step 8 +Check whether the certificate has been created by running the `kubectl get cert` command and if you see it as `True`, your certificate will be uploaded to your cluster in a few minutes. + +Now you can reach it as https://edge.domain.com and https://origin.domain.com + +## Sample Deployment File + +Ant Media Server has such a deployment file structure. This file has a few differences according to the deployment type. Here we will introduce the general file structure. + +```yaml +kind: Service +apiVersion: v1 +metadata: + name: ant-media-server +spec: + selector: + app: ant-media + ports: + - name: http + protocol: TCP + port: 5080 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ant-media-server +spec: + selector: + matchLabels: + app: ant-media + replicas: 1 + template: metadata: - name: ant-media-server-edge - annotations: - kubernetes.io/ingress.class: nginx - cert-manager.io/cluster-issuer: letsencrypt-production - nginx.ingress.kubernetes.io/affinity: "cookie" - nginx.ingress.kubernetes.io/session-cookie-name: "route" - nginx.ingress.kubernetes.io/session-cookie-expires: "172800" - nginx.ingress.kubernetes.io/session-cookie-max-age: "172800" + labels: + app: ant-media spec: - rules: - - host: edge.antmedia.cloud - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: ant-media-server-edge - port: - number: 5080 - - tls: - - hosts: - - edge.antmedia.cloud - secretName: ams-certificate-edge + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app + operator: In + values: + - ant-media + topologyKey: "kubernetes.io/hostname" + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + containers: + - name: ant-media-server + imagePullPolicy: IfNotPresent # change this value accordingly. It can be Never, Always or IfNotPresent + image: ant-media-server-enterprise-k8s:test #change this value according to your image. +# By default, mongodb deployment is used. If you're using mongodb somewhere else, specify it with server url(-h) below. +# You may also need to add -u and -p parameters for +# specifying mongodb username and passwords respectively + args: ["-g", "true", "-s", "true", "-r", "true", "-m", "cluster", "-h", "mongo"] + resources: + requests: + cpu: 4000m +``` +Here are the explanations for the common parameters and the changes parameters. + +### Common Parameters -**6**. After creating Ingress you should have tls secret in **kubectl get secret** output. +**The following parameters are common parameters independent of deployment type.**   - NAME TYPE DATA AGE - ams-certificate-origin kubernetes.io/tls 2 44m - ams-certificate-edge kubernetes.io/tls 2 44m - default-token-72fnb kubernetes.io/service-account-token 3 78m - ingress-nginx-admission Opaque 3 60m - ingress-nginx-token-ncck2 kubernetes.io/service-account-token 3 60m - sh.helm.release.v1.ingress-nginx.v1 helm.sh/release.v1 1 60m - +* **imagePullPolicy:** `IfNotPresent` means that if the image is available in local environment it will not pull from the private or public registry. +* **image:** `ant-media-server-enterprise-k8s:test` specifies the name of the image. You should pay attention here as it should be the same name as the image you built in previous step. +* **args:** `["-g", "true", "-s", "true", "-r", "true", "-m", "cluster", "-h", "127.0.0.1"]` specifies the parameters for running the Ant Media Server pods. Below we'll explain what they are used for. + * **`"-g", "true"`**: It means that Ant Media Server uses the public IP address of the host for internal cluster communication. Default value is false. + * **`"-s", "true"`**: It makes Ant Media Server uses its public IP address as the server name. + * **`"-r", "true"`**: It makes Ant Media Server replaces the local IP address in the ICE candidates with the server name. It's false by default. + * **` "-m", "cluster"`**: It specifies the server mode. It can be cluster or standalone. Its default value is standalone. If you're running Ant Media Server in Kubernetes, it's most likely you're running the Ant Media Server in cluster mode. This means you need to specify your MongoDB host, username, and password as parameter. + * **`"-h", "127.0.0.1"`**: It specifies the MongoDB host address. It's necessary to use if you're running in cluster mode. In this example, it's 127.0.0.1 because in the CI pipeline, local MongoDB is installed. You should change it with your own MongoDB address or replica set. + * **`"-u", "username"`**: It specifies the username to connect to MongoDB. If you don't have credentials, you don't need to specify. + * **`"-p", "password"`**: It specifies the password to connect to MongoDB. If you don't have credentials, you don't need to specify. + * **`"-l", "license number"`**: It makes Ant Media Server uses the license key. -**7.** Get the Load Balancer IP address with the **kubectl get ingress** command and add it to your DNS server. +### Deployment Specific Parameters - NAME CLASS HOSTS ADDRESS PORTS AGE - ant-media-server-origin `` origin.antmedia.cloud xxx.xxx.xxx.xxx 80, 443 26m - ant-media-server-edge `` edge.antmedia.cloud xxx.xxx.xxx.xxx 80, 443 26m +**The following parameters are different according to the deployment type.** -**8.** Check whether the certificate has been created by running the **kubectl get cert** command and if you see it as **True**, your certificate will be uploaded to your cluster in a few minutes. Then you can reach it as https://edge.yourdomain.com and [https://origin.domain.com](https://origin.domain.com) \ No newline at end of file +* **hostNetwork:** true line above means that Ant Media Server uses the host network. It is required as there is a wide range of UDP and TCP ports are being used for WebRTC streaming. This also means that you can only use one pod of Ant Media Server in a host instance. Don't worry about where and how to deploy as K8s handles that. We're just letting you know this to determine total number of nodes in your cluster. +* **affinity: TODO** +* **labels:** for origin edge distinction TODO \ No newline at end of file diff --git a/docs/guides/clustering-and-scaling/kubernetes/deploy-ams-with-helm.md b/docs/guides/clustering-and-scaling/kubernetes/deploy-ams-with-helm.md index de886dd8..bf3e1f41 100644 --- a/docs/guides/clustering-and-scaling/kubernetes/deploy-ams-with-helm.md +++ b/docs/guides/clustering-and-scaling/kubernetes/deploy-ams-with-helm.md @@ -1,5 +1,5 @@ --- -title: Deploy Ant Media Server with Helm +title: Helm Deployment description: Deploy Ant Media Server with Helm Charts keywords: [Deploy Ant Media Server with Helm Charts, Helm Charts, Ant Media Server Documentation, Ant Media Server Tutorials] sidebar_position: 5 @@ -7,99 +7,124 @@ sidebar_position: 5 # Deploy Ant Media Server with Helm Charts -To briefly mention Helm, Helm is a tool that allows you to manage applications on Kubernetes easily. It's possible to deploy, upgrade, and control versions with Helm. +Helm is a tool that enables the management of applications on a Kubernetes cluster. It's possible to deploy, upgrade, and control versions using Helm. -The key point, you can deploy Ant Media Server to your Kubernetes via Helm. Today, we are going to take a look at a step-by-step how to deploy Ant Media Server with helm. The part that excites me is that you can create an Ant Media Server Cluster environment with one click. +Ant Media Server can be easily deployed to a Kubernetes cluster via Helm with just one click. -Helm supports installations on Ubuntu and other distros. Before installing Helm on any operating system, it is necessary to set up a Kubernetes cluster. If Helm is not installed on your computer, you can follow the steps below for Ubuntu 20.04 and check this link for other distro downloads. +Helm supports installations on Ubuntu and other distros. Before installing Helm on any operating system, it is necessary to set up a Kubernetes cluster. If Helm is not installed on your computer, you can follow the steps below for Ubuntu 20.04 and also refer to the [Helm installation documentation](https://helm.sh/docs/intro/install/) for other distributions. -### Prerequisites +:::info +You will need to have the [Kubernetes command line tool](https://kubernetes.io/docs/tasks/tools/) and [Helm](https://helm.sh/docs/intro/install/) that package manager for Kubernetes installed on your computer. +::: + +## Visual Walkthrough: Video Guide + + + + +## Prerequisites - Kubernetes >= 1.23 (Your cluster must be ready and accessible) - Helm v3 - cert-manager -### Install Helm +## Install Helm -Install the helm tool by running the commands below. +Install the helm tool by running the following commands. -``` +```shell curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null sudo apt-get install apt-transport-https --yes echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list sudo apt-get update sudo apt-get install helm ``` -### Install the Ant Media Server Helm Chart +## Install the Helm Chart + +A Helm chart is a package that contains all the necessary resources to deploy an application to a Kubernetes cluster. This includes YAML configuration files for deployments, services, secrets, and config maps that define the desired state of your application. In this case, Ant Media Server. -Ant Media Server Helm chart installs the following +The Ant Media Server Helm chart installs the following: - MongoDB deployment - Origin deployment - Edge Deployment - Ingress controller -Add the AMS repository to Helm then install it as follows. +Add the Ant Media Server repository to Helm and install it using the following commands. -``` +```shell helm repo add antmedia https://ant-media.github.io/helm helm repo update helm install antmedia antmedia/antmedia --set origin={origin}.{example.com} --set edge={edge}.{example.com} --namespace antmedia --create-namespace ``` -After the installation is finished, 1 MongoDB pod, 1 Ant Media Origin pod, 1 Ant Media Edge pod, and Nginx Ingress will be installed (Go to the bottom of the page for available parameters.) and the output of **kubectl get pods -n antmedia** will be as follows. +After the installation is finished there will be: -``` + - 1 MongoDB pod + - 1 Ant Media Origin pod + - 1 Ant Media Edge pod + - Nginx Ingress will be installed (navigate to the end of this page for available parameters) + +The output of the command `kubectl get pods -n antmedia` should be as below. + +```shell NAME READY STATUS RESTARTS AGE ant-media-server-edge-7d8fd58f94-dwqbs 1/1 Running 0 2m15s ant-media-server-origin-57d974f4f7-655rf 1/1 Running 0 2m15s antmedia-ingress-nginx-controller-6b49f64bfc-zbblx 1/1 Running 0 2m15s mongo-69888cbbb9-d2zrc 1/1 Running 0          2m15s ``` -If the installation went as expected, run **kubectl get ingress -n antmedia** command to get your Ingress IP address and then update your DNS according to the ingress IP address and hostnames. +If the installation completed successfully, execute `kubectl get ingress -n antmedia` command to fetch the Ingress IP address so that the DNS records for the hostname can be updated. `kubectl get ingress -n antmedia` **Example Output** -``` +```shell NAME CLASS HOSTS ADDRESS PORTS AGE ant-media-server-origin origin.antmedia.cloud x.x.x.x 80, 443 9m45s ant-media-server-edge edge.antmedia.cloud x.x.x.x 80, 443   9m55s ``` -You can do a DNS query as follows. -``` +Confirm the DNS update by making a query: + +```shell dig origin.antmedia.cloud +noall +answer dig edge.antmedia.cloud +noall +answer ``` Example output: -``` -root@murat:~# dig edge.antmedia.cloud +noall +answer +```shell +root@murat:~$ dig edge.antmedia.cloud +noall +answer edge.antmedia.cloud. 300 IN A x.x.x.x ``` -If the result of this output is your Ingress IP address, your DNS has been updated so you can access via HTTPS (self-signed) or HTTP. +If the result of this output is the expected Ingress IP address, then the DNS has been updated successfully and Ant Media Server can be accessed via HTTPS (self-signed) or HTTP. -### Install SSL +## Install SSL -By default, a self-signed certificate comes in the Ant Media Server Kubernetes structure that you install with Helm. If you want, you can replace it with your own certificate as below or follow the steps below for Let's Encrypt. -``` +By default, a self-signed certificate comes in the Ant Media Server Kubernetes structure that is installed with Helm. If required, this can be replace with a custom certificate as shown below or follow the steps in further down to install via Let's Encrypt. + +```shell kubectl create -n antmedia secret tls ${CERT_NAME} --key ${KEY_FILE} --cert ${CERT_FILE} Use Let's Encrypt ``` -If you want, you can do this with the script we have prepared below or a step-by-step installation. -``` + +This can also be executed using a script through a guided installation process: + +```shell wget https://raw.githubusercontent.com/ant-media/helm/add_helm_repo/ams-k8s-ssl.sh bash ams-k8s-ssl.sh ``` -Then wait for the certificate to be created. +Expect a short pause while the certificate is being created. -If everything went well, the output of the **kubectl get -n antmedia** certificate command will show the value **True** as follows. -``` +If everything went well, the output of the `kubectl get -n antmedia` certificate command will show the value **True** as follows. + +```shell NAME READY SECRET AGE antmedia-cert-origin True antmedia-cert-origin 21m antmedia-cert-edge True antmedia-cert-edge 24m ``` -Then you can reach the Ant Media Edge/Origin instances over HTTPS. +Now Ant Media Server Edge/Origin instances can be accessed over HTTPS. +``` https://{origin}.{example}.{com} https://{edge}.{example}.{com} +``` -### Parameters +## Parameters You can customize the Ant Media Cluster installation using the following parameters. @@ -125,7 +150,6 @@ You can customize the Ant Media Cluster installation using the following paramet ## Example Usage -``` +```shell helm install antmedia antmedia/antmedia --set origin=origin.antmedia.io --set edge=edge.antmedia.io --set autoscalingEdge.targetCPUUtilizationPercentage=20 --set autoscalingEdge.minReplicas=2 --namespace antmedia --create-namespace - ``` diff --git a/docs/guides/clustering-and-scaling/kubernetes/install-ssl-on-kubernetes-using-lets-encrypt.md b/docs/guides/clustering-and-scaling/kubernetes/install-ssl-on-kubernetes-using-lets-encrypt.md deleted file mode 100644 index 4a365016..00000000 --- a/docs/guides/clustering-and-scaling/kubernetes/install-ssl-on-kubernetes-using-lets-encrypt.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -title: Install SSL on Kubernetes Using Let's Encrypt -description: Install SSL on Kubernetes Using Let's Encrypt -keywords: [Install SSL on Kubernetes Using Let's Encrypt, Let's Encrypt, Ant Media Server Documentation, Ant Media Server Tutorials] -sidebar_position: 3 ---- - -# Install SSL on Kubernetes Using Let's Encrypt - -Now let's move on to cert-manager installation. - - helm repo add jetstack https://charts.jetstack.iohelm repo updatehelm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --version v1.9.1 --set installCRDs=truekubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.9.1/cert-manager.crds.yaml - -Create a YAML file in your working directory and name it **ams-k8s-issuer-production.yaml** Add the following content (Do not forget to change the email address.) - - apiVersion: cert-manager.io/v1 - kind: ClusterIssuer - metadata: - name: letsencrypt-production - spec: - acme: - server: https://acme-v02.api.letsencrypt.org/directory - email: change_me - privateKeySecretRef: - name: letsencrypt-production - solvers: - - http01: - ingress: - class: nginx - -Let's deploy the YAML file that we created. - - kubectl create -f ams-production-issuer.yaml - -When you run the **kubectl get -n antmedia clusterissuers** command, you will see an output like the one below. - - letsencrypt-production True 1m - -We use the a**ntmedia-cert-edge** and **a****nt-media-cert-origin** secrets by default for the Origin and Edge sides, and we delete them because there are self-signed certificates. - - kubectl delete -n antmedia secret antmedia-cert-edge kubectl delete -n antmedia secret antmedia-cert-origin - -You must add an annotation **cert-manager.io/cluster-issuer: letsencrypt-production** in the ingress configuration with the issuer or cluster issuer name. - - kubectl annotate ingress cert-manager.io/cluster-issuer=letsencrypt-production --all - -If everything went well, the output of the **k****ubectl get -n antmedia certificate** command will show the value **True** as follows. - - NAME READY SECRET AGEantmedia-cert-origin True antmedia-cert-origin 21mantmedia-cert-edge True antmedia-cert-edge 24m - -And now you can access your Ant Media Server Cluster with your signed certificate. - -**https://origin.{example.com}** - -**https://edge.{example.com}** \ No newline at end of file diff --git a/docs/guides/clustering-and-scaling/kubernetes/installing-ams-on-aws-eks.md b/docs/guides/clustering-and-scaling/kubernetes/installing-ams-on-aws-eks.md deleted file mode 100644 index 232a52c8..00000000 --- a/docs/guides/clustering-and-scaling/kubernetes/installing-ams-on-aws-eks.md +++ /dev/null @@ -1,115 +0,0 @@ ---- -title: Installing Ant Media Server on AWS EKS -description: Installing Ant Media Server on AWS EKS -keywords: [Installing Ant Media Server on AWS EKS, AWS EKS, Ant Media Server Documentation, Ant Media Server Tutorials] -sidebar_position: 6 ---- - -# Installing Ant Media Server on AWS EKS - -In this post, we are going to guide you on how to run Ant Media Server on AWS EKS step by step. - -1\. After you are logged in to AWS, search the **EKS** keyword, find the **Elastic Kubernetes Service,** and click the **Add Cluster >` Create** button. - -![image.png](@site/static/img/image-286329.png) - -* * * - -2\. After setting a name for your cluster, the Kubernetes version and Cluster Service Role should be selected. You can follow this link to create a [Cluster Service Role](https://docs.aws.amazon.com/eks/latest/userguide/service_IAM_role.html). - -![image.png](@site/static/img/image-286429.png) - -* * * - -3\. In this section, subnets under VPC and VPC should be selected and a security group should be created. - -![image.png](@site/static/img/image-286529.png) - -Endpoint access should be selected as **Public** and the **Next** button is clicked. - -![image.png](@site/static/img/image-286629.png) - -* * * - -4\. You can activate the following options for logging. - -![image.png](@site/static/img/image-286729.png) - -* * * - -5\. Let’s check the configurations you set and create the cluster by clicking the **Create** button. - -![image.png](@site/static/img/image-286829.png) - -* * * - -6\. When your cluster’s status is changed from pending to active, click on the **Configuration >` Compute** tab and click on the **Add Node Group** button. - -![image.png](@site/static/img/image-286929.png) - -* * * - -7\. Type your node name and create the [Node IAM Role](https://docs.aws.amazon.com/eks/latest/userguide/create-node-role.html). - -![image.png](@site/static/img/image-287029.png) - -* * * - -8\. Click on the **Next** button after you configure the scaling of the **AMI type, Capacity type, Instance type, Disk and Node Group**. - -![image.png](@site/static/img/image-287129.png) - -* * * - -9\. Select your subnets and click on the **Next** button. - -![image.png](@site/static/img/image-287229.png) - -* * * - -10\. Finally, after checking the configurations, create the Node Pool by clicking on the **Create** button. - -![image.png](@site/static/img/image-287329.png) - -* * * - -11\. Update your Kubernetes **kubeconfig** settings as below, then list your nodes with the **kubectl get nodes** command. - - aws eks --region your_region update-kubeconfig --name clustername - - -![image.png](@site/static/img/image-287429.png) - -* * * - -12\. Now, it’s time to deploy the Ant Media Server. Create the **yaml** files in order as follows. - -First, you should organize your image field since you are going to change images. Here are the steps to organize your image field: - - wget https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-deployment.yaml - kubectl create -f ams-k8s-deployment.yaml - - - kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-hpa.yaml - kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-rtmp.yaml - wget https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-ingress.yaml - - -[Deploy the ingress.](https://github.com/ant-media/Ant-Media-Server/wiki/Kubernetes-Ingress) - -Once the changes on the **ams-k8s-ingress.yaml** file are done, let’s create our ingress. - - kubectl create -f ams-k8s-ingress.yaml - - -If everything works well, you will see the public IP address/domain name in the **kubectl get ingress** command’s output. After you make your DNS registration, you will be able to access over the domain you have determined. - -![image.png](@site/static/img/image-287529.png) - -Run **kubectl get services** command to get the RTMP address. You can send broadcasts over 1935 to the domain name that appears as EXTERNAL-IP. - -![image.png](@site/static/img/image-287629.png) - -When we check the AMS dashboard, we can see that 2 nodes have joined the cluster. - -![image.png](@site/static/img/image-287729.png) diff --git a/docs/guides/clustering-and-scaling/kubernetes/installing-ams-on-azure-aks.md b/docs/guides/clustering-and-scaling/kubernetes/installing-ams-on-azure-aks.md deleted file mode 100644 index 2d58d387..00000000 --- a/docs/guides/clustering-and-scaling/kubernetes/installing-ams-on-azure-aks.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -title: Installing Ant Media Server on Azure AKS -description: Installing Ant Media Server on Azure AKS -keywords: [Installing Ant Media Server on AWS EKS, AWS EKS, Ant Media Server Documentation, Ant Media Server Tutorials] -sidebar_position: 8 ---- - -# Installing Ant Media Server on Azure AKS - -In this document, you will see step-by-step instructions on how to run Ant Media Server Enterprise version on Azure Kubernetes Service (AKS). - ->> You need to have the Azure CLI software installed on your computer. - -**1.** After logging in to the Azure Portal, open the Kubernetes service and click on the **Create > Create a Kubernetes cluster** button. - -![](@site/static/img/azure-aks/azure-aks-1.png) - -**2.** After creating the Resource Group and configuring settings such as Region and Kubernetes cluster name, navigate to the **Next: Node pools** tab. - -![](@site/static/img/azure-aks/azure-aks-2.png) - -**3.** In the **Node pools** tab, enter the node pool (default agent pool) and make the desired changes according to your preferences. However, it is essential to ensure that **Enable public IP per node** is selected here. - -![](@site/static/img/azure-aks/azure-aks-3-1.png) -![](@site/static/img/azure-aks/azure-aks-3-2.png) - -**4.** Navigate to the **Review + create** tab and click **Create** to complete the setup (other settings are optional). - -![](@site/static/img/azure-aks/azure-aks-4.png) - -**5.** When the installation is complete, you will see a screen like the one below. And then Click on the **Connect to cluster** button. - -![](@site/static/img/azure-aks/azure-aks-5-1.png) - -Run the following commands to connect to the cluster from your local computer. - -![](@site/static/img/azure-aks/azure-aks-5-2.png) - -``` -az account set --subscription your-subscription -az aks get-credentials --resource-group your-resource-group --name your-cluster-name - -``` - - -**6.** After successfully accessing the cluster, let's add and update the Ant Media Helm repository as follows. - -``` -helm repo add antmedia https://ant-media.github.io/helm -helm repo update -``` - -And start the installation as follows (Don't forget to change your licenseKey and origin and edge values). - -``` -helm install antmedia antmedia/antmedia --set origin=origin.antmedia.cloud --set edge=edge.antmedia.cloud --set licenseKey="your-key" --set UseGlobalIP=false ---namespace antmedia --create-namespace -``` - -**7.** In Azure AKS, we need to use an Application Gateway for which you can select **Networking > Enable ingress controller** from your cluster, and then create the Application Gateway. - -![](@site/static/img/azure-aks/azure-aks-7.png) - -Then run the following command to enable Application Gateway Ingress. - -``` -kubectl annotate ingress -n antmedia kubernetes.io/ingress.class=azure/application-gateway --overwrite --all - -``` - -**8.** If everything works well, you will see the public IP address/domain name in the `kubectl get ingress -n antmedia` command’s output. After you make your DNS registration, you will be able to access over the domain you have determined. - -![](@site/static/img/azure-aks/azure-aks-8-1.png) - -Run kubectl get services command to get the RTMP address. You can send broadcasts over 1935 to the domain name that appears as EXTERNAL-IP. - -![](@site/static/img/azure-aks/azure-aks-8-2.png) diff --git a/docs/guides/clustering-and-scaling/kubernetes/kubernetes-autoscaling.md b/docs/guides/clustering-and-scaling/kubernetes/kubernetes-autoscaling.md deleted file mode 100644 index 5d083f9a..00000000 --- a/docs/guides/clustering-and-scaling/kubernetes/kubernetes-autoscaling.md +++ /dev/null @@ -1,170 +0,0 @@ ---- -title: Kubernetes Autoscaling -description: Kubernetes Autoscaling -keywords: [Kubernetes Autoscaling, Ant Media Server Documentation, Ant Media Server Tutorials] -sidebar_position: 4 ---- - -# Kubernetes Autoscaling - -Kubernetes lets you scale the pods automatically to optimize resource usage and make the backend ready according to the load in your service. Horizontal Pod Autoscaler which is a built-in component can scale your pods automatically. - -Firstly, we need to have a Metrics Server to collect the metrics of the pods. To provide metric via the Metrics API, a metric server monitoring must be deployed on the cluster. Horizontal Pod Autoscaler uses this API to collect metrics. - -Install Metric Server -===================== - -Metric Server is usually deployed by the cloud providers. If you are using a custom Kubernetes or the Metric Server is not deployed by your cloud provider you should deploy it manually as explained below. Firstly, Check if metrics-server is installed using the command below. - - kubectl get pods --all-namespaces | grep -i "metric" - -You are going to see an output exactly like the below. - - kube-system metrics-server-5bb577dbd8-7f58c 1/1 Running 7 23h - - - - -###     [](https://github.com/ant-media/Ant-Media-Server/wiki/Kubernetes-Autoscaling#manual-installation)Manual Installation - -Download the components.yaml file on the master. - - - - wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml - -Add the following line to line 132 of the file. ```--kubelet-insecure-tls```. The lines are going to seem exactly as below. - - spec: - containers: - - args: - - --kubelet-insecure-tls - - --cert-dir=/tmp - - --secure-port=4443 - - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname - - --kubelet-use-node-status-port - image: k8s.gcr.io/metrics-server/metrics-server:v0.4.2 - - - - -Deploy the YAML file that we have made changes. - - kubectl apply -f components.yaml - - - - -Check whether everything is working properly. - - kubectl get apiservices |grep "v1beta1.metrics.k8s.io" - - - -The output of the command should be as follows. - - v1beta1.metrics.k8s.io kube-system/metrics-server True 21h - - - -    [](https://github.com/ant-media/Ant-Media-Server/wiki/Kubernetes-Autoscaling#create-horizontal-pod-autoscaling)Create horizontal pod autoscaling -==================================================================================================================================================== - -First, make a small change in our yaml file in Ant Media Server by running```kubectl edit deployment ant-media-server```. Edit and save the following lines under the container according to yourself. Before proceeding let us tell you about Millicores. Millicores is a metric which is used to measure CPU usage. It is a CPU core divided into 1000 units (milli = 1000). 1000 = 1 core. So the below configuration uses 4 cores. - - resources: - requests: - cpu: 4000m - - - - -After adding file content should be like as follows: - - apiVersion: apps/v1 - kind: Deployment - metadata: - name: ant-media-server - spec: - selector: - matchLabels: - run: ant-media-server - replicas: 1 - template: - metadata: - labels: - run: ant-media-server - spec: - hostNetwork: true - containers: - - name: ant-media-server - imagePullPolicy: IfNotPresent # change this value accordingly. It can be Never, Always or IfNotPresent - image: ant-media-server-enterprise-k8s:test #change this value according to your image. - args: ["-g", "true", "-s", "true", "-r", "true", "-m", "cluster", "-h", "mongo"] - resources: - requests: - cpu: 4000m - - -Check the accuracy of the value we entered using the command below. - - kubectl describe deployment/ant-media-server - -Now that the deployment is running, we're going to create a Horizontal Pod Autoscaler for it: - - kubectl autoscale deployment ant-media-server --cpu-percent=60 --min=1 --max=10 - -or you can use the following yaml file: - - kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-hpa.yaml - -In the above configuration, we set the CPU average as 60% and we set the pods as min 1 and maximum 10. A new pod will be created every time the CPU average passes 60%. - -You can monitor the situation in the following output. - - root@k8s-master:~# kubectl get hpa - NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE - ant-media-server Deployment/ant-media-server 3%/60% 1 10 1 20h - -New pods are going to be created when we start loading and the cpu exceeds 60%. When the cpu average value decreases below 60%, then the pods are going to be terminated. - - root@k8s-master:~# kubectl get hpa - NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE - ant-media-server Deployment/ant-media-server 3%/60% 1 10 1 20h - -Check the number of pods running using the following command. - - root@k8s-master:~# kubectl get pods - NAME READY STATUS RESTARTS AGE - ant-media-server-7b9c6844b9-4dtwj 1/1 Running 0 42m - ant-media-server-7b9c6844b9-7b8hp 1/1 Running 0 19h - ant-media-server-7b9c6844b9-9rrwf 1/1 Running 0 18m - ant-media-server-7b9c6844b9-tdxhl 1/1 Running 0 47m - mongodb-9b99f5c-x8j5x 1/1 Running 0 20h - - - -    [](https://github.com/ant-media/Ant-Media-Server/wiki/Kubernetes-Autoscaling#utilities)Utilities ----------------------------------------------------------------------------------------------------- - -The following command gives information about AutoScale: - - kubectl get hpa - - - -Check the load of pods running using the command below: - - kubectl top nodes - - - -This command prints out the following: - - root@k8s-master:~# kubectl top node - NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% - k8s-node 111m 5% 717Mi 38% - k8s-node-2 114m 5% 1265Mi 68% - k8s-node-3 98m 4% 663Mi 35% - k8s-node-4 102m 5% 666Mi 35% - n8s-master 236m 11% 1091Mi 58% \ No newline at end of file diff --git a/docs/guides/clustering-and-scaling/kubernetes/kubernetes-services/_category_.json b/docs/guides/clustering-and-scaling/kubernetes/kubernetes-services/_category_.json new file mode 100644 index 00000000..ff190aea --- /dev/null +++ b/docs/guides/clustering-and-scaling/kubernetes/kubernetes-services/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Kubernetes Services", + "position": 1, + "link": { + "type": "generated-index", + "description": "This guide will help you to deploy Ant Media Server with Kubernetes by setting-up correct enviroment. Also, achive auto-Scaling and set-up SSL for Kubernetes." + } +} diff --git a/docs/guides/clustering-and-scaling/kubernetes/install-ams-at-digital-ocean.md b/docs/guides/clustering-and-scaling/kubernetes/kubernetes-services/install-ams-at-digital-ocean.md similarity index 68% rename from docs/guides/clustering-and-scaling/kubernetes/install-ams-at-digital-ocean.md rename to docs/guides/clustering-and-scaling/kubernetes/kubernetes-services/install-ams-at-digital-ocean.md index ad0cbc13..f9951562 100644 --- a/docs/guides/clustering-and-scaling/kubernetes/install-ams-at-digital-ocean.md +++ b/docs/guides/clustering-and-scaling/kubernetes/kubernetes-services/install-ams-at-digital-ocean.md @@ -1,45 +1,52 @@ --- -title: How to Install Ant Media Server on Digital Ocean with just One Click +title: K8s by Digital Ocean description: Install Ant Media Server on Digital Ocean with just One Click keywords: [How to Install Ant Media Server on Digital Ocean with just One Click, One Click Application, Digital Ocean, Ant Media Server Documentation, Ant Media Server Tutorials] sidebar_position: 7 --- -# How to Install Ant Media Server on Digital Ocean with just One Click +# Installing Ant Media Server on K8s by Digital Ocean +In this article, I'm going to explain how to install Ant Media Server K8s on DigitalOcean with just one click. -In this article I m going to explain how to install Ant Media Server K8s on DigitalOcean with just one click. +:::info +You need to have the [Kubernetes command line tool](https://kubernetes.io/docs/tasks/tools/) installed on your computer. +::: -In this article, I'm going to explain how to install Ant Media Server K8s on DigitalOcean with just one click. +## Step 1: Install Ant Media Server App Login to Digital Ocean, click on the Marketplace tab. -![image.png](@site/static/img/ams-do-marketpace-1.png) +![image.png](@site/static/img/kubernetes/ams-do-marketpace-1.png) Then enter **"Ant Media Server Enterprise"** in the search field and select it as shown in the screenshot. -![image.png](@site/static/img/ams-do-marketpace-2.png) +![image.png](@site/static/img/kubernetes/ams-do-marketpace-2.png) Click **"Install App"** and then click **"Install"**. -![image.png](@site/static/img/ams-do-marketpace-3.png) +![image.png](@site/static/img/kubernetes/ams-do-marketpace-3.png) + +## Step 2: Install the Kubernetes Cluster Choose the location, NodePool, and other settings and start the cluster setup. -![image.png](@site/static/img/ams-do-marketpace-4-1.png) -![image.png](@site/static/img/ams-do-marketpace-4-2.png) +![image.png](@site/static/img/kubernetes/ams-do-marketpace-4-1.png) +![image.png](@site/static/img/kubernetes/ams-do-marketpace-4-2.png) + +## Step 3: Connect to Kubernetes After the installation is complete, download the kubernetes configuration file from the **Actions > Download Config** menu and export it as follows. -``` +```shell export KUBECONFIG=~/Downloads/ant-media-k8s-1-26-3-do-0-fra1-1679679927785-kubeconfig.yaml ``` Let's check everything is working. -``` +```shell kubectl get pods -n antmedia ``` -``` +```shell NAME READY STATUS RESTARTS AGE ant-media-server-edge-6bc98b95d7-hrdlj 1/1 Running 0 6m49s ant-media-server-origin-7d56c5f8d-sp2nl 1/1 Running 0 6m49s @@ -47,29 +54,33 @@ antmedia-ingress-nginx-controller-755b7f6fb8-kmwrm 1/1 Running 0 mongo-7946fc86ff-lzjnr 1/1 Running 0 6m49s ``` -``` +```shell kubectl get ingress -n antmedia ``` -``` + +```shell NAME CLASS HOSTS ADDRESS PORTS AGE ant-media-server-edge nginx origin.localhost x.x.x.x 80, 443 11m ant-media-server-origin nginx edge.localhost x.x.x.x 80, 443 11m ``` - +## Step 4: Configure Hostnames Unfortunately, the domain/subdomain cannot be determined during the installation in DigitalOcean, so update your Edge and Origin HOSTS addresses as follows. -``` + +```shell kubectl patch ing/ant-media-server-origin --type=json -p='[{"op": "replace", "host": "edge.antmedia.cloud", "value":"test"}]' -n antmedia kubectl patch ing/ant-media-server-origin --type=json -p='[{"op": "replace", "host": "edge.antmedia.cloud", "value":"test"}]' -n antmedia ``` -Make sure your own domains are updated when you run the kubectl get ingress -n antmedia command again then you can update your dns. +Make sure your own domains are updated when you run the `kubectl get ingress -n antmedia` command again, then you can update your DNS. You can now access your Ant Media Cluster over Ingress. +``` https://edge.{yourdomain}.com http://origin.{yourdomain}.com +``` -The Marketplace product comes with a self-signed certificate. If you want to use Let's Encrypt or your own certificate, you can follow the below document. +## Step 5: Setup SSL -https://github.com/ant-media/helm#installing-ssl +The Marketplace product comes with a self-signed certificate. If you want to use Let's Encrypt or your own certificate, follow the documentation to [install an SSL certificate via Helm](/guides/clustering-and-scaling/kubernetes/deploy-ams-with-helm/#install-ssl) diff --git a/docs/guides/clustering-and-scaling/kubernetes/kubernetes-services/installing-ams-on-aws-eks.md b/docs/guides/clustering-and-scaling/kubernetes/kubernetes-services/installing-ams-on-aws-eks.md new file mode 100644 index 00000000..d6f81970 --- /dev/null +++ b/docs/guides/clustering-and-scaling/kubernetes/kubernetes-services/installing-ams-on-aws-eks.md @@ -0,0 +1,139 @@ +--- +title: AWS Elastic Kubernetes Service +description: Installing Ant Media Server on AWS EKS +keywords: [Installing Ant Media Server on AWS EKS, AWS EKS, Ant Media Server Documentation, Ant Media Server Tutorials] +sidebar_position: 6 +--- + +# Installing Ant Media Server on Amazon Elastic Kubernetes Service (EKS) + +:::info +You need to have the [AWS CLI software](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) and the [Kubernetes command line tool](https://kubernetes.io/docs/tasks/tools/) installed on your computer. +::: + +## Step 1: Navigate to EKS Service + +After logging into AWS, search for the **EKS** service and find the **Elastic Kubernetes Service,** then click the **Add Cluster > Create** button. + +![image.png](@site/static/img/image-286329.png) + +* * * + +## Step 2: Name the Kubernetes Cluster + +After setting a name for the cluster, the Kubernetes version and Cluster Service Role should be selected. You can follow this link to create a [Cluster Service Role](https://docs.aws.amazon.com/eks/latest/userguide/service_IAM_role.html). + +![image.png](@site/static/img/image-286429.png) + +* * * + +## Step 3: Configure Networking + +In this section, subnets under VPC and VPC should be selected and a security group should be created. + +![image.png](@site/static/img/image-286529.png) + +Endpoint access should be selected as **Public** and the **Next** button is clicked. + +![image.png](@site/static/img/image-286629.png) + +* * * + +## Step 4: Optionally Setup Logging + +You can activate the following options for logging. + +![image.png](@site/static/img/image-286729.png) + +* * * + +## Step 5: Create the Cluster + +Let’s confirm the configurations have been set correctly and create the cluster by clicking the **Create** button. + +![image.png](@site/static/img/image-286829.png) + +* * * + +## Step 6: Create a Node Group + +When your cluster’s status is changed from pending to active, click on the **Configuration > Compute** tab and click on the **Add Node Group** button. + +![image.png](@site/static/img/image-286929.png) + +* * * + +Type your node name and create the [Node IAM Role](https://docs.aws.amazon.com/eks/latest/userguide/create-node-role.html). + +![image.png](@site/static/img/image-287029.png) + +* * * + +## Step 7: Scaling Configure + +Click on the **Next** button after you configure the scaling of the **AMI type, Capacity type, Instance type, Disk and Node Group**. + +![image.png](@site/static/img/image-287129.png) + +* * * + +## Step 9: Select Subnets + +Select your subnets and click on the **Next** button. + +![image.png](@site/static/img/image-287229.png) + +* * * + +## Step 10: Create the Node Pool + +Finally, after checking the configurations, create the Node Pool by clicking on the **Create** button. + +![image.png](@site/static/img/image-287329.png) + +* * * + +## Step 11: Update Kubernetes Cluster + +Update the Kubernetes cluster `kubeconfig` settings and then list the nodes with the `kubectl get nodes` command. + + aws eks --region your_region update-kubeconfig --name clustername + + +![image.png](@site/static/img/image-287429.png) + +* * * +## Step 12: Deploy Ant Media Server + +Now, it’s time to deploy Ant Media Server on the Kubernetes cluster by creating the `yaml` files. + +First, you should organize your image field since you are going to change images. Here are the steps to organize your image field: + +```shell +wget https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-deployment.yaml +kubectl create -f ams-k8s-deployment.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-hpa.yaml +kubectl create -f https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-rtmp.yaml +wget https://raw.githubusercontent.com/ant-media/Scripts/master/kubernetes/ams-k8s-ingress.yaml +``` + + +[Deploy the ingress.](/guides/clustering-and-scaling/kubernetes/deploy-ams-on-kubernetes/#kubernetes-ingress) + +Once the changes on the **ams-k8s-ingress.yaml** file are done, let’s create our ingress. + +```shell +kubectl create -f ams-k8s-ingress.yaml +``` + +If everything works well, you will see the public IP address/domain name in the **kubectl get ingress** command’s output. After you make your DNS registration, you will be able to access over the domain you have determined. + +![image.png](@site/static/img/image-287529.png) + +Run **kubectl get services** command to get the RTMP address. You can send broadcasts over 1935 to the domain name that appears as EXTERNAL-IP. + +![image.png](@site/static/img/image-287629.png) + +When we check the Ant Media Server dashboard, we can see that 2 nodes have joined the cluster. + +![image.png](@site/static/img/image-287729.png) diff --git a/docs/guides/clustering-and-scaling/kubernetes/kubernetes-services/installing-ams-on-azure-aks.md b/docs/guides/clustering-and-scaling/kubernetes/kubernetes-services/installing-ams-on-azure-aks.md new file mode 100644 index 00000000..2283185b --- /dev/null +++ b/docs/guides/clustering-and-scaling/kubernetes/kubernetes-services/installing-ams-on-azure-aks.md @@ -0,0 +1,92 @@ +--- +title: Azure Kubernetes Service +description: Installing Ant Media Server on Azure AKS +keywords: [Installing Ant Media Server on AWS EKS, AWS EKS, Ant Media Server Documentation, Ant Media Server Tutorials] +sidebar_position: 8 +--- + +# Installing Ant Media Server on Azure AKS + +In this document, you will see step-by-step instructions on how to run Ant Media Server Enterprise version on Azure Kubernetes Service (AKS). + +:::info +You need to have the [Azure CLI software](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) and the [Kubernetes command line tool](https://kubernetes.io/docs/tasks/tools/)installed on your computer. +::: + +## Step 1: Create a Kubernetes Cluster + +After logging in to the Azure Portal, open the Kubernetes service and click on the **Create > Create a Kubernetes cluster** button. + +![](@site/static/img/azure-aks/azure-aks-1.png) + +After creating the Resource Group and configuring settings such as Region and Kubernetes cluster name, navigate to the **Next: Node pools** tab. + +![](@site/static/img/azure-aks/azure-aks-2.png) + +## Step 2: Configure Node Pools + +In the **Node pools** tab, enter the node pool (default agent pool) and make the desired changes according to your preferences. However, it is essential to ensure that **Enable public IP per node** is selected here. + +![](@site/static/img/azure-aks/azure-aks-3-1.png) +![](@site/static/img/azure-aks/azure-aks-3-2.png) + +## Step 3: Review and Create Cluster + +Navigate to the **Review + create** tab and click **Create** to complete the setup (other settings are optional). + +![](@site/static/img/azure-aks/azure-aks-4.png) + +## Step 4: Connect to Cluster + +When the installation is complete, you will see a screen like the one below. And then Click on the **Connect to cluster** button. + +![](@site/static/img/azure-aks/azure-aks-5-1.png) + +Run the following commands to connect to the cluster from your local computer. + +![](@site/static/img/azure-aks/azure-aks-5-2.png) + +``` +az account set --subscription your-subscription +az aks get-credentials --resource-group your-resource-group --name your-cluster-name + +``` +## Step 5: Install Ant Media Server via Helm + +After successfully accessing the cluster, let's add and update the Ant Media Helm repository as follows. + +``` +helm repo add antmedia https://ant-media.github.io/helm +helm repo update +``` + +And start the installation as follows + +:::warning +Don't forget to change your licenseKey, origin and edge values. +::: + +``` +helm install antmedia antmedia/antmedia --set origin=origin.antmedia.cloud --set edge=edge.antmedia.cloud --set licenseKey="your-key" --set UseGlobalIP=false +--namespace antmedia --create-namespace +``` + +## Step 6: Configure Ingress Controller + +In Azure AKS, we need to use an Application Gateway for which you can select **Networking > Enable ingress controller** from your cluster, and then create the Application Gateway. + +![](@site/static/img/azure-aks/azure-aks-7.png) + +Then run the following command to enable Application Gateway Ingress. + +```shell +kubectl annotate ingress -n antmedia kubernetes.io/ingress.class=azure/application-gateway --overwrite --all +``` + +If the installation and configuration was successful, the public IP address/domain name will be output when running the command `kubectl get ingress -n antmedia`. After making the DNS registration, you will be able to access Ant Media Server using the hostname thats been configured. + +![](@site/static/img/azure-aks/azure-aks-8-1.png) + +Execute the `kubectl get svc -n antmedia` command to fetch the RTMP address from the `EXTERNAL-IP` column to start live streaming using RTMP on port 1935. + +![](@site/static/img/azure-aks/azure-aks-8-2.png) diff --git a/docs/guides/clustering-and-scaling/kubernetes/prepare-environment-to-deploy-ams-at-kubernetes.md b/docs/guides/clustering-and-scaling/kubernetes/prepare-environment-to-deploy-ams-at-kubernetes.md index e1549a5c..5209837c 100644 --- a/docs/guides/clustering-and-scaling/kubernetes/prepare-environment-to-deploy-ams-at-kubernetes.md +++ b/docs/guides/clustering-and-scaling/kubernetes/prepare-environment-to-deploy-ams-at-kubernetes.md @@ -1,5 +1,5 @@ --- -title: Preparation of Kubernetes Environment for AMS Deployment +title: K8s Preparation description: Preparation of Kubernetes Environment for AMS Deployment keywords: [Kubernetes Environment for AMS Deployment, Ant Media Server Deployment, Ant Media Server Documentation, Ant Media Server Tutorials] sidebar_position: 1 @@ -11,23 +11,21 @@ Kubernetes as known is the open source container orchestration tool that is wide Let us show how to use Ant Media Server with Kubernetes. -Introduction ------------- +## Introduction The scope of this document is giving you the basics about how to run Ant Media Server Kubernetes Cluster. If you're not familiar with [Kubernetes](https://kubernetes.io/docs/home/) then you can get started with Kubernetes and follow [interactive tutorials.](https://kubernetes.io/docs/tutorials/kubernetes-basics/create-cluster/cluster-intro/) Running Ant Media Server in Kubernetes is fully about clustering. If you are not familiar with Ant Media Server Clustering & Scaling, please read the [Cluster & Scaling documentation](/v1/docs/clustering-and-scaling-ant-media-server). -You should have some prerequisites to deploy AMS Cluster on Kubernetes. +You should have some prerequisites to deploy Ant Media Server Cluster on Kubernetes. -Prerequisites -------------- +## Prerequisites -### 1\. Docker Image +### Docker Image -First of all, you should have an AMS docker image as scaling unit. You can create your own docker image or you can pull it from the docker repositories like Docker Hub, AWS. +First of all, you should have an Ant Media Server docker image as scaling unit. You can create your own docker image or you can pull it from the docker repositories like Docker Hub, AWS. -#### Create image for container +#### Create a Docker Image We first need to create a docker image to run our pods in Kubernetes. @@ -36,31 +34,30 @@ We first need to create a docker image to run our pods in Kubernetes. wget https://raw.githubusercontent.com/ant-media/Scripts/master/docker/Dockerfile_Process \ -O Dockerfile_Process - - - * Download or copy AMS Enterprise Edition ZIP file into the same directory that you download Dockerfile above. * Create the docker image. Before running the command below, please pay attention that you should replace {CHANGE\_YOUR\_ANT\_MEDIA\_SERVER\_ZIP\_FILE} in the command below with your exact Ant Media Server ZIP file name. - sudo docker build --network=host --file=Dockerfile_Process -t ant-media-server-enterprise-k8s:test --build-arg AntMediaServer={CHANGE_YOUR_ANT_MEDIA_SERVER_ZIP_FILE} . +```shell +sudo docker build --network=host --file=Dockerfile_Process -t ant-media-server-enterprise-k8s:test --build-arg AntMediaServer={CHANGE_YOUR_ANT_MEDIA_SERVER_ZIP_FILE} . +``` -The second thing we should point out is the image name and tag. The command above use the ```ant-media-server-enterprise-k8s:test``` as image name and tag. The image name is compatible with the deployment file. I mean you can absolutely change the image name and tag, just make it compatible with the deployment file we'll mention soon. +The second thing we should point out is the image name and tag. The command above use the `ant-media-server-enterprise-k8s:test` as image name and tag. The image name is compatible with the deployment file. I mean you can absolutely change the image name and tag, just make it compatible with the deployment file we'll mention soon. If everything is OK, your image is available in your environment. If you're going to use this image in AWS EKS or a similar service, you need to upload the image to repository such as [AWS ECR](https://aws.amazon.com/ecr/) or you can run a [local registry.](https://docs.docker.com/registry/deploying/#run-a-local-registry) -#### Pulling Ready Images from Repositories +#### Pulling Images from Repositories You can get ready images from the following repositories. **Docker Hub**: antmedia/enterprise:latest -### 2\. Kubernetes Cluster +## Kubernetes Cluster -#### Own Kubernetes Cluster +### Own Kubernetes Cluster You can create your own Kubernetes Cluster [on your servers.](https://antmedia.io/scale-ant-media-server-with-kubernetes/) -#### Cloud Services +### Cloud Services You can have a Kubernetes Cluster on the cloud services. You will find blog posts about how to create such a Kubernetes cluster below. @@ -68,55 +65,51 @@ You can have a Kubernetes Cluster on the cloud services. You will find blog post * [Digital Ocean](https://antmedia.io/how-to-create-kubernetes-cluster-on-digital-ocean/)  * [OVH](https://antmedia.io/auto-scaling-streaming-server-with-kubernetes/) - -Install Metric Server (for Auto Scaling) -======================================== +## Install Metric Server -Metric Server is usually deployed by the cloud providers. If you are using a custom Kubernetes or the Metric Server is not deployed by your cloud provider you should deploy it manually as explained below. Firstly, Check if metrics-server is installed using the command below. +A metric server is used for autoscaling and is usually deployed by the cloud providers. If you are using a custom Kubernetes or the Metric Server is not deployed by your cloud provider you should deploy it manually as explained below. Firstly, Check if metrics-server is installed using the command below. - - kubectl get pods --all-namespaces | grep -i "metric" +```shell +kubectl get pods --all-namespaces | grep -i "metric" +``` You are going to see an output exactly like the below. - - kube-system metrics-server-5bb577dbd8-7f58c 1/1 Running 7 23h - +```shell +kube-system metrics-server-5bb577dbd8-7f58c 1/1 Running 7 23h +``` -###   [](https://github.com/ant-media/Ant-Media-Server/wiki/Kubernetes-Autoscaling#manual-installation)Manual Installation +### Manual Installation Download the components.yaml file on the master. - wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml +```shell +wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml +``` Add the following line to line 132 of the file. ```--kubelet-insecure-tls```. The lines are going to seem exactly as below. - - Deploy the YAML file that we have made changes. - - kubectl apply -f components.yaml - +```shell +kubectl apply -f components.yaml +``` - Check whether everything is working properly. - - kubectl get apiservices |grep "v1beta1.metrics.k8s.io" - +```shell +kubectl get apiservices |grep "v1beta1.metrics.k8s.io" +``` - The output of the command should be as follows. +```shell +v1beta1.metrics.k8s.io kube-system/metrics-server True 21h +``` - v1beta1.metrics.k8s.io kube-system/metrics-server True 21h - -### [](https://github.com/ant-media/Ant-Media-Server/wiki/Kubernetes-Autoscaling#create-horizontal-pod-autoscaling) - -#### 3\. Preparing MongoDB +## Preparing MongoDB MongoDB is essential to create an Ant Media Server cluster. Before running Ant Media Server nodes, you should prepare it first. You can run it anywhere that can be accessible from the Ant Media Server nodes with the one of the following ways. @@ -126,7 +119,7 @@ MongoDB is essential to create an Ant Media Server cluster. Before running Ant M Whichever way you deploy Mongo DB, you should note the IP, user name, and password if exists. We will use them soon. -#### 4\. Determine the Deployment Type +### Determine the Deployment Type You can deploy your AMS onto Kubernetes in 2 ways: with HostNetwork or without HostNetwork. diff --git a/docusaurus.config.js b/docusaurus.config.js index 4c86f336..e35fa123 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -90,7 +90,7 @@ const config = { }, { from: '/guides/clustering-and-scaling/aws/installing-ams-on-aws-eks/', - to: '/guides/clustering-and-scaling/kubernetes/installing-ams-on-aws-eks/' + to: '/guides/clustering-and-scaling/kubernetes/kubernetes-services/installing-ams-on-aws-eks/' }, { from: '/guides/developer-sdk-and-api/rest-api-guide/enabling-ip-filtering-behind-load-balancer-in-aws/', diff --git a/static/img/ams-do-marketpace-1.png b/static/img/kubernetes/ams-do-marketpace-1.png similarity index 100% rename from static/img/ams-do-marketpace-1.png rename to static/img/kubernetes/ams-do-marketpace-1.png diff --git a/static/img/ams-do-marketpace-2.png b/static/img/kubernetes/ams-do-marketpace-2.png similarity index 100% rename from static/img/ams-do-marketpace-2.png rename to static/img/kubernetes/ams-do-marketpace-2.png diff --git a/static/img/ams-do-marketpace-3.png b/static/img/kubernetes/ams-do-marketpace-3.png similarity index 100% rename from static/img/ams-do-marketpace-3.png rename to static/img/kubernetes/ams-do-marketpace-3.png diff --git a/static/img/ams-do-marketpace-4-1.png b/static/img/kubernetes/ams-do-marketpace-4-1.png similarity index 100% rename from static/img/ams-do-marketpace-4-1.png rename to static/img/kubernetes/ams-do-marketpace-4-1.png diff --git a/static/img/ams-do-marketpace-4-2.png b/static/img/kubernetes/ams-do-marketpace-4-2.png similarity index 100% rename from static/img/ams-do-marketpace-4-2.png rename to static/img/kubernetes/ams-do-marketpace-4-2.png