One place for hosting & domains

      Rancher

      Настройка многоузловых развертываний с Rancher 2.1, Kubernetes и Docker Machine в Ubuntu 18.04


      Автор выбрал Code Org для получения пожертвования в рамках программы Write for DOnations.

      Введение

      Rancher — это популярная платформа управления контейнерами с открытым исходным кодом. Выпущенная в начале 2018 года версия Rancher 2.X работает на Kubernetes и включает новые инструменты, такие как управление несколькими кластерами и встроенные CI конвейеры. Помимо повышенной безопасности, масштабируемости и простых инструментов развертывания, уже имеющихся в Kubernetes, Rancher предлагает графический пользовательский интерфейс, упрощающий управление контейнерами. Благодаря графическому интерфейсу Rancher пользователи смогут управлять секретами, безопасно обрабатывать роли и разрешения, масштабировать узлы и поды, а также выполнять настройку средств распределения нагрузки и томов без необходимости использования инструментов командной строки или сложных файлов YAML.

      В этом руководстве мы будем разворачивать многоузловой сервер Rancher 2.1 с помощью Docker Machine в Ubuntu 18.04. По окончании руководства вы сможете предоставить новые дроплеты DigitalOcean и поды контейнеров через пользовательский интерфейс Rancher для быстрого расширения или сокращения вашей среды хостинга.

      Предварительные требования

      Перед прохождением этого обучающего руководства вам потребуется учетная запись DigitalOcean, а также следующее:

      • Маркер персонального доступа DigitalOcean, который вы можете создать в соответствии с указаниями этого руководства. Этот маркер позволит Rancher получить через API доступ к учетной записи DigitalOcean.

      • Полное зарегистрированное доменное имя с записью A, которая указывает на IP-адрес дроплета, создаваемый на шаге 1. Вы можете узнать, как привязывать домены к дроплетам DigitalOcean, ознакомившись с документацией по доменам и DNS DigitalOcean. В данном руководстве замените example.com на ваш домен.

      Шаг 1 — Создание дроплета с установленным Docker

      Чтобы запустить и настроить Rancher, вам нужно будет создать новый дроплет с установленным Docker. Для этого нужно использовать образ Docker DigitalOcean.

      Войдите в учетную запись DigitalOcean и выберите Create Droplet (Создать дроплет). Затем в разделе Choose an Image (Выбрать образ) выберите вкладку Marketplace (Магазин). Выберите Docker 18.06.1~ce~3 on 18.04.

      Выберите образ Docker 18.06 в меню доступных одним нажатием приложений

      Далее выберите дроплет размером не менее 2 ГБ и укажите регион центра обработки данных для вашего дроплета.

      После этого добавьте ключи SSH, укажите имя хоста для дроплета и нажмите Create (Создать).

      Может потребоваться несколько минут для организации работы сервера и загрузки Docker. После успешного развертывания дроплета вы можете запустить Rancher в новом контейнере Docker.

      Шаг 2 — Запуск и настройка Rancher

      Дроплет, созданный на шаге 1, будет запускать Rancher в контейнере Docker. На этом шаге вы запустите контейнер Rancher и убедитесь, что у него есть сертификат SSL от Let’s Encrypt для получения защищенного доступа к панели администратора Rancher. Let’s Encrypt — это автоматизированный издатель сертификатов с открытым исходным кодом, позволяющий разработчикам получать действующие в течение 90 дней сертификаты SSL бесплатно.

      Выполните вход в новый дроплет:

      Чтобы убедиться, что Docker запущен, введите:

      Проверьте, что указанная версия Docker соответствует вашим ожиданиям. Вы можете запустить Rancher с уже установленным сертификатом Let’s Encrypt с помощью следующей команды:

      • docker run -d --restart=unless-stopped -p 80:80 -p 443:443 -v /host/rancher:/var/lib/rancher rancher/rancher --acme-domain example.com

      Параметр --acme-domain устанавливает сертификат SSL от Let’s Encrypt для обеспечения того, что администратор Rancher обслуживается через HTTPS. Этот скрипт также указывает дроплету выполнить выборку образа Docker rancher/rancher и запускать экземпляр Rancher в контейнере, который автоматически перезапускается в случае аварийного завершения работы. Для облегчения восстановления в случае потери данных скрипт монтирует том на компьютер хоста (в /host/rancher), который содержит данные Rancher.

      Для просмотра всех запущенных контейнеров введите:

      Вы увидите примерно следующий вывод (с уникальным идентификатором и именем контейнера):

      Output

      CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7b2afed0a599 rancher/rancher "entrypoint.sh" 12 seconds ago Up 11 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp wizardly_fermat

      Если контейнер не запущен, вы можете снова запустить команду docker run.

      Прежде чем вы сможете получить доступ к панели администратора Rancher, вам нужно будет задать пароль администратора и URL-адрес сервера Rancher. Интерфейс администратора Rancher позволит вам получить доступ ко всем запущенным узлам, подам и секретам, поэтому важно использовать надежный пароль.

      Перейдите к доменному имени, которое указывает на ваш новый дроплет, в браузере. При первом посещении этого адреса Rancher попросит задать пароль:

      Установка пароля Rancher с помощью диалогового окна

      При запросе URL-адреса сервера Rancher используйте доменное имя, указывающее на ваш дроплет.

      Теперь, когда вы выполнили настройку сервера Rancher, вы увидите домашний экран администратора Rancher:

      Домашний экран администратора Rancher

      Вы можете перейти к настройке кластера Rancher.

      Шаг 3 — Настройка кластера с одним узлом

      Для использования Rancher вам потребуется создать кластер с как минимум одним узлом. Кластер — это группа с одним или несколькими узлами. В этом руководстве вы найдете более подробную информацию об архитектуре Kubernetes. В настоящем руководстве узлы соответствуют дроплетам, которыми управляет Rancher. Поды представляют собой группу запущенных контейнеров Docker внутри дроплета. Каждый узел может запускать множество подов. В пользовательском интерфейсе Rancher вы можете настроить кластеры и узлы в лежащей в его основе среде Kubernetes.

      К концу этого шага у вас должен быть настроенный кластер с одним узлом, готовый к запуску первого пода.

      В Rancher нажмите Add Cluster (Добавить кластер) и выберите DigitalOcean в качестве поставщика инфраструктуры.

      Выбор DigitalOcean из включенных в список поставщиков инфраструктуры

      Откройте меню Cluster Name (Имя кластера) и прокрутите до раздела Node Pools (Пулы узлов). Введите Name Prefix (Префикс имени), оставьте значение 1 для параметра Count (Счетчик) и проверьте etcd, Control Plane (Уровень управления) и Worker (Рабочее приложение).

      • etcd — это система хранения значения ключа Kubernetes для сохранения состояния вашей среды. Для обеспечения высокой доступности вам нужно запустить три или пять узлов etcd, чтобы, если один из узлов перестанет работать, ваша среда оставалась под контролем.
      • Control Plane (Уровень управления) проверяет все объекты Kubernetes, например поды, в вашей среде и поддерживает их соответствие конфигурации, которую вы задаете в интерфейсе администратора Rancher.
      • Workers (Рабочие приложения) запускают действующие рабочие нагрузки и агенты мониторинга, которые обеспечивают, что ваши контейнеры будут работать и останутся подключены к сети. Рабочие узлы — это место, где ваши поды будут запускать программное обеспечение, которое вы разворачиваете.

      Создание пула узлов с одним узлом

      Перед созданием кластера нажмите Add Template Node (Добавить шаблон узла) для настройки конкретных параметров вашего нового узла.

      Введите персональный маркер доступа DigitalOcean в поле ввода Access Token (Маркер доступа) и нажмите Next: Configure Droplet (Далее: настройка дроплета).

      Далее выберите тот же Region (Регион) и Droplet Size (Размер дроплета), что и в шаге 1. Для Image (Образ) выберите Ubuntu 16.04.5 x64, так как в настоящее время существует проблема совместимости Rancher с Ubuntu 18.04. Нажмите Create (Создать) для сохранения шаблона.

      После этого нажмите Create (Создать) на странице Add Cluster (Добавить кластера) для завершения процесса предоставления. Rancher потребуется несколько минут на выполнение этого шага, но после завершения работы вы увидите новый дроплет в панели управления дроплетов DigitalOcean.

      На этом шаге вы создали новый кластер и узел, где вы будете разворачивать рабочую нагрузку в следующем разделе.

      Шаг 4 — Развертывание рабочей нагрузки веб-приложения

      Когда новый кластер и узел будут готовы, вы можете развернуть ваш первый под в рабочей нагрузке. Под Kubernetes — это самая маленькая часть работы, доступная в Kubernetes и расширении Rancher. Рабочие нагрузки описывают одну группу подов, которые вы разворачиваете вместе. Например, вы можете запустить несколько подов вашего веб-сервера в одной рабочей нагрузке, чтобы убедиться, что, если один под замедляется при получении конкретного запроса, другие экземпляры могут обрабатывать входящие запросы. В этом разделе вы должны будете развернуть образ Nginx Hello World в одном поде.

      Наведите курсор на Global (Глобально) в заголовке и выберите Default (По умолчанию). В результате будет отображена панель проекта по умолчанию. В этом руководстве вы будете работать над развертыванием отдельного проекта, но в этой панели управления вы также можете создать несколько проектов для получения сред для изолированных контейнеров.

      Для начала настройки первого пода нажмите Deploy (Развернуть).

      Откройте Name (Имя) и введите nginxdemos/hello в поле Docker Image (Образ Docker). Затем разметьте порт 80 в контейнере для порта 30000 на узлах хоста. Это позволит гарантировать, что поды, которые вы разворачивайте, будут доступны на каждом узле порта 30000. Вы можете оставить для параметра Protocol (Протокол) значение TCP, а в следующем выпадающем списке укажите NodePort.

      Примечание. Хотя этот метод запуска узла на порте каждого узла легче использовать, Rancher также включает Ingress для распределения нагрузки и прекращения работы SSL для использования в продакшене.

      Форма ввода для развертывания рабочей нагрузки

      Для запуска пода прокрутите до самого низа и нажмите Launch (Запустить).

      Rancher вернет вас на домашнюю страницу проекта по умолчанию, а в течение нескольких секунд ваш под будет готов. Нажмите ссылку 30000/tcp под именем рабочей нагрузки, и Rancher откроет новую вкладку с информацией о среде запущенного контейнера.

      Адрес сервера, имя сервера и другие результаты работы запущенного контейнера NGINX

      Адрес сервера и порт, которые вы видите на этой странице, повторяют данные внутренней сети Docker, а не являются публичным IP-адресом, который вы видите в браузере. Это означает, что Rancher работает и перенаправляет трафик с http://first_node_ip:30000/ на рабочую нагрузку, как и ожидалось.

      В данный момент вы успешно развернули вашу первую рабочую нагрузку одного пода на отдельном узле Rancher. Далее вы узнаете, как можно расширить вашу среду Rancher.

      Шаг 5 — Масштабирование узлов и подов

      Rancher предоставляет два способа масштабирования ресурсов хостинга: увеличение числа подов в вашей рабочей нагрузке или увеличение числа узлов вашего кластера.

      Добавление подов в вашу рабочую нагрузку будет предоставлять вашему приложению большее количество запущенных процессов. Это позволит ему обрабатывать больше трафика и добиться развертываний без остановки работы приложений, но каждый узел сможет обрабатывать только ограниченное количество подов. Когда все ваши узлы достигнут лимита на количество подов, вам нужно будет увеличить количество узлов, если вы захотите продолжить масштабирование вашего приложения.

      Еще одним соображением, которое нужно учитывать, является тот факт, что, хотя увеличение количества подов выполняется бесплатно, вам придется платить за каждый узел, добавляемый в вашу среду. На этом шаге вы сможете расширить количество узлов и подов, а также добавить дополнительный узел в ваш кластер Rancher.

      Примечание. В этой части руководства будет предоставлен новый дроплет DigitalOcean автоматически через API, поэтому вы должны учитывать, что запуск второго узла будет сопровождаться дополнительными расходами.

      Перейдите на домашнюю страницу кластера установки Rancher, выбрав Cluster: your-cluster-name в верхней панели навигации. Далее нажмите Nodes (Узлы) в верхней панели навигации.

      Использование выпадающего меню верхней панели для выбора кластера

      Эта страница показывает, что у вас в кластере есть один запущенный узел. Для добавления дополнительных узлов нажмите Edit Cluster (Изменить кластер) и прокрутите до раздела Node Pools (Пулы узлов) внизу страницы. Нажмите Add Node Pool (Добавить пул узлов), введите префикс и проверьте поле Worker (Рабочее приложение). Нажмите Save (Сохранить) для обновления кластера.

      Добавление пула узла в качестве единого рабочего приложения

      В течение 2–5 минут Rancher предоставит второй дроплет и отметит узел как Active (Активный) в панели управления кластера. Этот второй узел — только рабочее приложение, что означает, что он не будет использовать etcd Rancher или контейнеры панели управления. Это предоставляет рабочему приложению больше возможностей для запуска рабочих нагрузок.

      Примечание. При наличии нечетного числа узлов etcd будет гарантировано, что всегда можно будет достичь кворума (или консенсуса). Если у вас есть только один узел etcd, вы сталкиваетесь с риском того, что ваш кластер может стать недоступным, если этот один узел прекратит работу. В продакшен-среде лучше использовать три или пять узлов etcd.

      Когда второй узел будет готов, вы сможете увидеть рабочую нагрузку, которую вы развернули на предыдущем шаге, на этом узле, если перейдете на http://send_node_ip:30000/ в браузере.

      Масштабирование узлов позволяет вам использовать больше дроплетов для распределения ваших рабочих нагрузок, но вы также можете использовать несколько экземпляров каждого пода внутри рабочей нагрузки. Для добавления дополнительных подов вернитесь на страницу проекта по умолчанию, нажмите стрелку слева от рабочей нагрузки hello-world и нажмите + два раза для добавления двух новых подов.

      Запуск трех подов Hello World в рабочую нагрузку

      Rancher автоматически развернет несколько подов и распределит запущенные контейнеры на каждом узле, в зависимости от доступности.

      Теперь вы можете масштабировать ваши узлы и поды согласно требованиям вашего приложения.

      Заключение

      Вы выполнили развертывание нескольких узлов с помощью Rancher 2.1 в Ubuntu 18.04, а также расширили вашу конфигурацию до двух запущенных узлов и нескольких подов внутри рабочей нагрузки. Вы можете использовать эту стратегию для размещения и масштабирования любых контейнеров Docker, которые вам нужно запускать в вашем приложении, и использовать панель управления и оповещения Rancher для максимального повышения производительности ваших рабочих нагрузок и узлов внутри кластера.



      Source link

      Cómo configurar implementaciones multinodo con Rancher 2.1, Kubernetes y Docker Machine en Ubuntu 18.04


      El autor seleccionó a Code Org para recibir una donación como parte del programa Write for DOnations.

      Introducción

      Rancher es una popular plataforma de administración de contenedores de código abierto. Rancher 2.X , lanzada a principios del 2018, funciona en Kubernetes y ha incorporado nuevas herramientas, como la administración multiclúster y canales de integración continua (CI) incorporados. Además de la seguridad mejorada, la escalabilidad y las herramientas de implementación fáciles de usar ya disponibles en Kubernetes, Rancher ofrece una interfaz gráfica de usuario (GUI) que facilita más la administración de los contenedores. A través dela GUI de Rancher, los usuarios pueden administrar secretos, gestionar funciones y permisos de forma segura, escalar nodos y pods, y configurar equilibradores de carga y volúmenes sin necesidad de una herramienta de línea de comandos ni de archivos YAML complejos.

      A través de este tutorial, implementará un servidor multinodo de Rancher 2.1 usando Docker Machine en Ubuntu 18.04. Al final del tutorial, podrá suministrar nuevos Droplets y pods de contenedor de DigitalOcean a través de la UI de Rancher para expandir o reducir su entorno de alojamiento.

      Requisitos previos

      Antes de comenzar este tutorial, deberá contar con una cuenta de DigitalOcean y con lo siguiente:

      • Un token de acceso personal de DigitalOcean, que puede crear siguiendo las instrucciones de este tutorial. Este token permitirá que Rancher tenga acceso de API a su cuenta de DigitalOcean.

      • Un nombre de dominio completamente registrado con un registro A que apunte a la dirección IP del Droplet que creó en el paso 1. Puede aprender a apuntar dominios a los Droplets de DigitalOcean leyendo la documentación sobre dominios y DNS de DigitalOcean. A lo largo de este tutorial, sustituya su dominio por example.com.

      Paso 1: Crear un droplet con Docker instalado

      Para iniciar y configurar Rancher, deberá crear un nuevo droplet con Docker instalado. Para conseguir esto, puede usar la imagen de Docker de DigitalOcean.

      Primero, inicie sesión en su cuenta de DigitalOcean y seleccione Crear Droplet. A continuación, en la sección Choose an image, seleccione la pestaña Marketplace. Elija Docker 18.06.1~ce~~3 en 18.04.

      Seleccione la imagen de Docker 18.06 del menú One-click Apps

      A continuación, seleccione un droplet que no tenga un tamaño inferior a 2 GB y una región de centro de datos para este.

      Finalmente, añada sus claves SSH, proporcione un hombre de host para su droplet y pulse el botón Create.

      Serán necesarios unos minutos para que el servidor se abastezca y Docker se descargue. Una vez que el droplet se implemente correctamente, estará listo para iniciar Rancher en un nuevo contenedor de Docker.

      Paso 2: Iniciar y configurar Rancher

      El droplet que creó en el paso 1 ejecutará Rancher en un contenedor de Docker. En este paso, iniciará el contenedor de Rancher y se asegurará de que cuente con un certificado SSL de Let’s Encrypt para que pueda acceder de forma segura al panel de administración de Rancher. Let´s Encrypt es una autoridad de certificación automática de código de código abierto que permite a los desarrolladores proporcionar certificados SSL por 90 días gratis.

      Inicie sesión en su nuevo droplet:

      Para asegurarse de que Docker esté en ejecución, introduzca lo siguiente:

      Compruebe que la versión de Docker listada sea la que espera. Puede iniciar Rancher con un certificado de Let’s Encrypt que ya esté instalado ejecutando el siguiente comando:

      • docker run -d --restart=unless-stopped -p 80:80 -p 443:443 -v /host/rancher:/var/lib/rancher rancher/rancher --acme-domain example.com

      La opción --acme-domain instala un certificado SSL de Let’s Encrypt para garantizar que su administrador Rancher se presente en HTTPS: Esta secuencia de comandos también indica al droplet que busque la imagen de Docker rancher/rancher e inicie una instancia de Rancher en un contenedor que se reiniciará automáticamente si se desconecta de forma accidental. Para facilitar la recuperación en caso de pérdida de datos, la secuencia de comandos monta un volumen en la máquina host (en /host/rancher) que contiene los datos de host.

      Para ver todos los contenedores en ejecución, introduzca lo siguiente:

      Verá un resultado similar al siguiente (con un ID y nombre de contenedor únicos):

      Output

      CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7b2afed0a599 rancher/rancher "entrypoint.sh" 12 seconds ago Up 11 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp wizardly_fermat

      Si el contenedor no está en ejecución, puede ejecutar el comando docker run nuevamente.

      Para poder acceder al panel de administración de Rancher, deberá configurar su contraseña de administrador y la URL del servidor de Rancher. La interfaz de administrador de Rancher le brindará acceso a todos sus nodos en ejecución, pods y secretos. Por ello, es importante que utilice una contraseña segura para ello.

      Vaya al nombre de dominio que apunta a su nuevo droplet en su navegador web. La primera vez que visite esta dirección, Rancher le permitirá establecer una contraseña:

      Establezca su contraseña de Rancher usando la línea de comandos

      Cuando se solicite su URL del servidor de Rancher, utilice el nombre de dominio orientado a su droplet.

      Con esto, habrá completado la configuración del servidor de Rancher y verá la pantalla de inicio de administración de Rancher:

      Pantalla de inicio de administración de Rancher

      Está listo para continuar con la configuración del clúster de Rancher.

      Paso 3: Configurar un clúster con un nodo único

      Para usar Rancher, deberá crear un clúster que tenga al menos un nodo. Un clúster es un grupo de uno o más nodos. Esta guía le proporcionará más información sobre la arquitectura de Kubernetes. En este tutorial, los nodos se corresponden con los droplets que Rancher administrará. Los pods representan un grupo de contenedores de Docker en ejecución en el droplet. Cada nodo puede ejecutar muchos pods. Usando la UI de Rancher, puede configurar clústeres y nodos en un entorno subyacente de Kubernetes.

      Al final de este paso, habrá configurado un clúster con un único nodo listo para ejecutar su primer pod.

      En Rancher, haga clic en Add Cluster y seleccione DigitalOcean como proveedor de infraestructura.

      Seleccione DigitalOcean en la lista de proveedores de infraestructura.

      Introduzca un nombre en Cluster Name *y desplácese hasta la sección *Node Pools. Introduzca un prefijo en Name Prefix, deje Count en el valor 1 por el momento y seleccione etcd, Control Plane y Worker.

      • etcd es un sistema de almacenamiento de valores de claves de Kubernetes pensado para mantener todo el estado del entorno. A fin de preservar una alta disponibilidad, debería ejecutar tres o cinco nodos etcd para que, si uno se desactiva, siga siendo posible administrar su entorno.
      • Control Plane verifica todos los objetos de Kubernetes, como los pods, en su entorno y los mantiene actualizados con la configuración que proporcione en la interfaz de administración de Rancher.
      • Workers ejecutará las cargas de trabajo reales y los agentes de monitorización para garantizar que sus contenedores continúen en ejecución y en red. Los nodos de trabajo se encuentran donde sus pods ejecutarán el software que implemente.

      Cree un grupo de nodos con un único nodo

      Antes de crear el clúster, haga clic en Add Node Template a fin de configurar las opciones específicas para su nuevo nodo.

      Introduzca su Token de acceso personal de DigitalOcean en el cuadro de entrada Access Token y haga clic en Next: Configure Droplet.

      A continuación, seleccione los mismos valores para Region y Droplet Size que en el paso 1. En el caso de Image, asegúrese de seleccionar Ubuntu 16.04.5 x64, ya que actualmente existe un problema de compatibilidad entre Rancher y Ubuntu 18.04. Pulse Create para guardar la plantilla.

      Finalmente, haga clic en Crear en la página Add Cluster para iniciar el proceso de aprovisionamiento. Rancher tardará unos minutos en completar este paso, pero verá un nuevo Droplet en su panel de control de droplets de DigitalOcean cuando esto suceda.

      A lo largo de este paso, creó un nuevo clúster y nodo en los cuales implementará una carga de trabajo en la siguiente sección.

      Paso 4: Implementar una carga de trabajo de aplicación web

      Una vez que el clúster y el nodo nuevos estén listos, puede implementar su primer pod en una carga de trabajo. Un pod de Kubernetes es la unidad de trabajo más pequeña disponible para Kubernetes y, por extensión, para Rancher. Las cargas de trabajo describen un grupo único de pods que implementa juntos. Por ejemplo, puede ejecutar varios pods de su servidor web en una única carga de trabajo para garantizar que si un pod se ralentiza con una solicitud concreta otras instancias puedan gestionar las solicitudes entrantes. En esta sección, implementará una imagen de Nginx Hello World en un único pod.

      Posicione el cursor sobre Global en el encabezado y seleccione Default. Con esto, accederá al panel de control de proyecto Default. Se centrará en implementar un único proyecto en este tutorial, pero desde este panel de control también puede crear varios para conseguir entornos de alojamiento de contenedores aislados.

      Para comenzar a configurar su primer pod, haga clic en Deploy.

      Introduzca un nombre en Name y nginxdemos/hello en el campo Docker Image. A continuación, asigne el puerto 80 del contenedor al puerto 30000 *de los nodos host. Esto garantizará que los pods que implemente estén disponibles en cada nodo en el puerto 30000. Puede dejar el valor *TCP para Protocol y NodePort en el siguiente elemento desplegable.

      Nota: Aunque este método para ejecutar el pod en cada puerto del nodo es más sencillo para comenzar, Rancher también incluye Ingress a fin de proporcionar equilibrio de carga y terminación SSL para el uso en producción.

      Formulario de entrada para implementar una carga de trabajo

      Para iniciar el pod, desplácese hasta la parte inferior y haga clic en Launch.

      Rancher lo direccionará a la página de inicio del proyecto predeterminado, y en unos segundos su pod estará listo. Haga clic en el enlace 30000/tcp justo debajo del nombre de la carga de trabajo. Rancher abrirá una nueva pestaña con información sobre el entorno del contenedor en ejecución.

      Dirección del servidor, nombre del servidor y otros resultados del contenedor de NGINX en ejecución

      Los** valores de Server add**ess y de puerto que ve en esta página son los de la red interna de Docker. No pertenecen a la dirección IP pública que ve en su navegador. Esto significa que Rancher funciona y dirige el tráfico de http://first_node_ip:30000/ a la carga de trabajo, como se espera.

      En este punto, habrá implementado correctamente su primera carga de trabajo de un pod en un nodo único de Rancher. A continuación, verá cómo escalar su entorno Rancher.

      Paso 5: Escalar nodos y pods

      Rancher le proporciona dos formas de escalar sus recursos de alojamiento: aumentar el número de pods de su carga de trabajo o aumentar el número de nodos de su clúster.

      Añadir pods a su carga de trabajo le proporcionará a su aplicación más procesos en ejecución. Esto le permitirá gestionar más tráfico y habilitar implementaciones sin tiempo de inactividad, pero cada nodo solo puede gestionar un número finito de pods. Una vez que todos sus nodos hayan alcanzado su límite de pods, deberá aumentar el número de nodos si desea continuar con la expansión.

      Otro aspecto que se debe tener en cuenta es que, si bien el aumento de pods es normalmente gratuito, tendrá que pagar por cada nodo que añada a su entorno. A lo largo de este paso, escalará ambos nodos y pods, y añadirá otro nodo a su clúster de Rancher.

      Nota: En esta parte del tutorial, se proporcionará un nuevo droplet de DigitalOcean automáticamente a través de la API. Por lo tanto, tenga en cuenta que deberá afrontar costos adicionales mientras el segundo nodo esté en ejecución.

      Diríjase a la página de inicio del clúster de su instalación de Rancher seleccionando Cluster: nombre-de-su-clúster en la barra de navegación superior. A continuación, haga clic en Nodes en la barra de navegación superior.

      Utilice el elemento desplegable de la barra de navegación superior para seleccionar su clúster

      En esta página se muestra que actualmente dispone de un nodo en ejecución en el clúster. Para añadir nodos, haga clic en Edit Cluster y desplácese hasta la sección Node Pools en la parte inferior de la página. Haga clic en Add Node Pool, introduzca un prefijo y seleccione la casilla Worker. Haga clic en Save para actualizar el clúster.

      Agregar un grupo de nodos únicamente como trabajador

      En un plazo de dos a cinco minutos, Rancher proporcionará un segundo droplet y marcará el nodo con la indicación Active en el panel de control del clúster. Este segundo nodo es solo un trabajador, lo cual significa que no ejecutará los contenedores de etcd o Control Plane de Rancher. Esto brinda al trabajador más capacidad para ejecutar cargas de trabajo.

      Nota: Disponer de un número desigual de nodos de etcd garantizará que estos siempre puedan alcanzar un cuórum (o consenso). Si solo dispone de un nodo de etcd, correrá el riesgo de que no sea posible alcanzar su clúster si ese nodo se desactiva. En un entorno de producción, es mejor ejecutar tres o cinco nodos de etcd.

      Cuando el segundo nodo esté listo, podrá ver la carga de trabajo que implementó en el paso anterior en este nodo visitando http://segundo_node_ip:30000/ en su navegador.

      La expansión de nodos le proporciona más droplets para distribuir sus cargas de trabajo, pero es posible que también desee ejecutar más instancias de cada pod en una carga de trabajo. Para añadir más pods, vuelva a la página del proyecto con el valor default, pulse la flecha a la izquierda de su carga de trabajo hello-world y haga clic en + dos veces para añdir dos pods más.

      Ejecutar tres pods de Hello World en una carga de trabajo

      Rancher implementará de forma automática más pods y distribuirá los contenedores en ejecución a cada nodo, según dónde haya disponibilidad.

      Ahora, podrá escalar sus nodos y pods para satisfacer los requisitos de su aplicación.

      Conclusión

      De esta manera, habrá configurado implementaciones multinodo usando Rancher 2.1 en Ubuntu 18.04 y habrá aplicado una expansión a dos nodos en ejecución y varios pods en una carga de trabajo. Puede usar esta estrategia para alojar y escalar cualquier tipo de contenedor de Docker que deba ejecutar en su aplicación, y usar el panel de control y las alertas de Rancher para maximizar el rendimiento de sus cargas de trabajo y nodos en cada clúster.



      Source link

      How to Deploy Kubernetes on Linode with Rancher 2.2


      Updated by Linode Written by Linode

      Rancher title graphic.

      What is Rancher?

      Rancher is a web application that provides an interactive and easy-to-use GUI for creating and managing Kubernetes clusters. Rancher has plugins for interacting with multiple cloud hosts, including Linode, and you can manage clusters across different hosting providers.

      Rancher also maintains a curated list of apps that offer simple configuration options and a click-to-deploy interface. If you prefer to deploy your apps from a Helm chart, you can do that too.

      Guide Outline

      This guide will show how to:

      • Install Rancher on a Linode

      • Deploy a Kubernetes cluster on Linode using Rancher

      • Deploy an app from the Rancher app library to your cluster

      • Take advantage of the Linode CCM and CSI for Kubernetes via Rancher.

      If you are not familiar with Kubernetes and container deployments, we recommend that you review our other guides on these subjects first.

      Caution

      This guide’s example instructions will create several billable resources on your Linode account. If you do not want to keep using the example cluster that you create, be sure to remove it when you have finished the guide.

      If you remove the resources afterward, you will only be billed for the hour(s) that the resources were present on your account.

      If You Already Run Rancher

      If you already run Rancher and would like to start creating clusters on Linode, you can skip to the Activate the Linode Node Driver and Deploy a Kubernetes Cluster sections. The Deploy an App section will show how you can take advantage of the Linode CCM and CSI.

      You may need to update your local Rancher installation to see the Linode node driver as an option.

      Before You Begin

      The Rancher web application will run on a Linode in your Cloud Manager account. Create and prepare the Linode that will run Rancher:

      1. Create a Linode running Ubuntu 18.04 in the data center of your choice. Follow the Getting Started guide for instructions on setting up your server. It is recommended that you create a 2GB Linode or larger.

        Note

        You will be able to create Kubernetes clusters in any Linode data center from the Rancher UI, even if your Rancher Linode is located in a different region.

      2. The Rancher web application is run inside a Docker container, so you will also need to install Docker CE on your Linode. Follow the instructions for installing Docker CE on Ubuntu 18.04 and then return to this guide.

      You will also need to generate an API token and prepare a domain zone:

      1. Rancher will need a Linode APIv4 token from your Linode account in order to create your cluster. Review the instructions from the Getting Started with the Linode API guide to get a token.

      2. The Set Up DNS section of this guide will assign an address to this guide’s example app. In order to do so, you must already have a domain zone created in the Linode Cloud Manager. If you do not have a zone created, review the instructions from our DNS Manager guide.

        Note

        If you haven’t purchased a domain name, then you can read along with the DNS section of this guide without implementing it in your own cluster.

      Install Rancher

      After you have your Linode up and running with Docker, you can then install and run Rancher:

      1. Log in to your Linode via SSH:

        ssh [email protected]
        
      2. Create a rancher directory inside /opt; this folder will hold settings and keys for Rancher:

        sudo mkdir -p /opt/rancher
        
      3. Run Rancher:

        docker run -d -p 80:80 -p 443:443 
          --restart=unless-stopped 
          -v /opt/rancher:/var/lib/rancher 
          rancher/rancher:latest
        
        • The --restart option ensures that the application will be restarted if the Linode is ever rebooted.
        • The -v option binds the /opt/rancher directory on the Linode to the container so that the application can persist its data.
      4. Visit your Linode’s IP address in your browser. Your browser will display an SSL certificate warning, but you can bypass it.

        Note

        If you are interested in setting up an SSL certificate with Rancher, you may consider also creating an NGINX container with an SSL certificate that proxies traffic to the Rancher container.

      5. You should see a welcome screen from Rancher. Enter a new password for the default administrative user for Rancher (which is named admin) and click Continue:

        Rancher first load screen

      6. The server URL entry form will appear, which should already show your Rancher server’s IP address. Click the Save URL button to continue:

        Rancher enter server URL screen

      7. The default home page for your Rancher app will appear. This page normally displays a list of all of your Kubernetes clusters. Since you have not created a cluster yet, a placeholder image is shown instead:

        Rancher enter server URL screen

        Note

        The main interface for navigating Rancher is via the blue navigation bar that spans the top of the page. The items in this navigation bar will change when you view different parts of the application.

      8. Before you can create your first cluster, you will need to enable Linode’s integration with Rancher. Proceed to the Activate the Linode Node Driver for Rancher section.

      Activate the Linode Node Driver for Rancher

      Rancher includes two kinds of integrations with hosting providers:

      • A cluster driver allows Rancher to create and administer a cloud host-launched Kubernetes cluster. In a host-launched Kubernetes cluster, your hosting platform operates the new cluster’s control plane and etcd components, while you provision and configure your worker nodes (via Rancher as well).

      • A node driver allows Rancher to create and administer a Rancher-launched Kubernetes cluster. Rancher will directly provision your control plane and etcd nodes along with your worker nodes. Your cloud host does not manage your control plane and etcd components.

      Rancher is shipped with a node driver for Linode, but it is inactive by default. To activate the Linode node driver:

      1. Click on Tools from the main navigation bar and select Drivers from the dropdown menu.

        Rancher Drivers menu option highlighted

      2. Click on the Node Drivers tab:

        Rancher Node Drivers tab highlighted

      3. Scroll down to Linode’s driver. Click the corresponding more options ellipsis and click on the Activate item in the dropdown menu that appears:

        Rancher activate Linode node driver

      4. Activating the Linode node driver does not install the Linode CCM and CSI for your new clusters. Further instructions for enabling these features are listed in the Deploy a Kubernetes Cluster section. You should wait until the node driver is listed as Active before moving on.

        What are the Linode CCM and CSI?

        The CCM (Cloud Controller Manager) and CSI (Container Storage Interface) are Kubernetes addons published by Linode. These addons provide additional integrations with the Linode cloud platform. Specifically, you can use them to create NodeBalancers, DNS records, and Block Storage Volumes.

      Deploy a Kubernetes Cluster

      Add a Node Template

      Node templates are used by Rancher to provision cluster nodes. When you create a node template, you can specify configuration parameters, like the region, instance type, and Linux image that should be used for any node in the cluster. You can set different templates for different clusters, which allows you to choose the right resources for your different workloads.

      Before provisioning your cluster, you will need to add the node template it will use. To add a node template:

      1. Click on your User Avatar icon in the upper right-hand corner and select Node Templates.

        Click on the User Avatar icon

      2. On the Node Templates page, click on the Add Template button in the upper right-hand corner.

      3. The Add Node Template dialog will appear, select Linode from the list of providers and enter in your Linode APIv4 token in the API Token field.

        Add Node Template dialog window

      4. Click on the Next: Configure Instances button.

      5. Another dialog will appear which accepts options for your new node template. Under the Instance Options section, set the preferred region, instance type, and Linux image for your nodes, along with any Cloud Manager tags you’d like to apply to your nodes.

        Rancher Add Node Template form - Linode options

        Note

        We recommend that you choose a Linode 2GB or higher for the nodes in a Kubernetes cluster. The Block Storage service has not been deployed to our Atlanta (US-Southeast) data center. Since this guide will use Block Storage Volumes in its example cluster, please choose a different region when creating your node template.

      6. Enter a name for your template. This can be arbitrary, but it’s helpful to call it something that will help you remember the options you set in the template form, like newark-linode8gb-ubuntu1804.

        Rancher Add Node Template form - template name

      7. When finished with the form, click the Create button.

        Note

        All other node template settings are optional and will not be used in this guide. You do not need to set a password for the nodes created through this template; Rancher will generate one automatically. As well, Rancher provides command-line access to the Kubernetes API for your cluster, so logging into your nodes generally isn’t needed.

      8. You will be returned to the Node Templates page where your node template will be visible.

        Rancher Node Template list page

      Provision a Cluster

      1. Return to the home page by hovering over the Global dropdown menu in the main navigation bar and then clicking the Global menu item:

        Rancher return to the global view

      2. Click on the Add Cluster button. The Add Cluster form will appear.

      3. Select the Linode driver from the From nodes in an infrastructure provider section:

        Rancher Add Cluster form - Linode node driver selected

      4. Enter a name for your cluster in the Cluster Name field. The name for our example cluster will be example-cluster.

      5. In the Node Pools section, under the Template column, you should see the node template you created in the previous section of this guide. Set a value for the Name Prefix field. For each Linode that Rancher creates for that node pool, the Linode will be prefixed according to the name you set (e.g. if the name prefix is example-cluster-, then your Linodes will be named example-cluster-1, example-cluster-2, etc.

        Rancher Add Cluster form - Add Node Template button highlighted

        • A node pool is Rancher’s method for creating the nodes (Linodes) that form your cluster. You specify how many nodes should be in a node pool, along with the node template for those nodes in that pool. If Rancher later detects that one of the nodes has lost connectivity with the cluster, it will automatically create a new one.

        • When configuring a node pool, you also specify which of your cluster’s components operate on the nodes in the pool. For example, you can have one pool that only runs your cluster’s etcd database, another pool which only runs your control plane components (the Kubernetes API server, scheduler, and controller manager), and a third pool which runs your application workloads.

      6. Set the value for the Count field to 3. Rancher will create 3 Linodes for the node pool.

      7. Toggle on the checkboxes for etcd, Control Plane, and Worker. In our example cluster, the nodes for this node pool will run each of these components. Your configured form should look like the following:

        Rancher Add Node Template form - single node pool configuration

        Note

        When you set up a cluster for production, avoid having a node pool that runs your workloads alongside your etcd or control plane components. An example node pool configuration which splits the etcd and control plane components from your workloads would look like the following:

        Rancher Add Node Template form - example production node pool configuration

        Review Rancher’s Production Ready Cluster documentation for more guidance on setting up production clusters.

      8. The last part in creating your cluster is to configure Linode’s CCM and CSI. In the Cluster Options section, toggle on the Custom option for the Cloud Provider field, then click on the Edit as YAML button above the section.

        Rancher Add Node Template form - example production node pool configuration

      9. A text editor will appear:

        Rancher Add Cluster form - YAML editor

      10. Insert the following snippet before the first line in the editor (above the addon_job_timeout declaration):

         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        
        addons_include:
          - https://linode.github.io/rancher-ui-driver-linode/releases/v0.2.0/linode-addons.yml
        addons: |-
          ---
          apiVersion: v1
          kind: Secret
          metadata:
            name: linode
            namespace: kube-system
          stringData:
            token: "..."
            region: "..."
          ---
      11. Insert your Linode APIv4 token in the token field from this snippet. Also, enter the label for your node template’s data center in the region field. This label should be lower-case (e.g. us-east instead of US-East).

      12. Scroll down in the editor to the services section. Remove the existing services section and replace it with this snippet:

         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        
        services:
          etcd:
            backup_config:
              interval_hours: 12
              retention: 6
            creation: "12h"
            extra_args:
              heartbeat-interval: 500
              election-timeout: 5000
            retention: "72h"
            snapshot: true
          kube-api:
            always_pull_images: false
            pod_security_policy: false
            service_node_port_range: "30000-32767"
            extra_args:
              feature-gates: "PersistentLocalVolumes=true,VolumeScheduling=true,CSINodeInfo=true,CSIDriverRegistry=true,BlockVolume=true,CSIBlockVolume=true"
          kubelet:
            fail_swap_on: false
            extra_args:
              cloud-provider: "external"
              feature-gates: "PersistentLocalVolumes=true,VolumeScheduling=true,CSINodeInfo=true,CSIDriverRegistry=true,BlockVolume=true,CSIBlockVolume=true"
          kube-controller:
            extra_args:
              cloud-provider: "external"
      13. After you finish with both of these steps, your YAML should resemble this completed snippet.

        Note

        Avoid copying and pasting the entire completed snippet example, as it has some variable values outside of the addons_include, addons, and services sections that may not match your deployment (e.g. the kubernetes_version setting).

        Instead, compare your YAML file with the completed example to ensure you have inserted the addons_include, addons, and services sections in the right places.

      14. Click the Create button below the YAML editor. You will be returned to the global home page, and your new cluster will be listed (in the Provisioning state):

        Rancher Global home page with new cluster listed

      15. If you visit the list of your Linodes in the Linode Cloud Manager, you will see the new nodes in your cluster:

        Linode Cloud Manager - new cluster nodes

        Note

        If your nodes do not not appear in the Linode Cloud Manager as expected, then you may have run into a limit on the number of resources allowed on your Linode account. Contact Linode Support if you believe this may be the case.

      Explore the New Cluster

      1. To inspect your new cluster, click on its name in the global list of clusters:

        Rancher home page - new cluster highlighted

        Or, hover over the Global menu and then select the name of the new cluster:

        Rancher cluster selection menu

      2. Your cluster’s dashboard will appear. If it is still provisioning, it will display a placeholder graphic:

        Rancher cluster dashboard

      3. Note that the items in the main navigation bar will change when viewing a cluster:

        Rancher navigation bar - cluster mode

      4. Click on the Nodes main menu item:

        Rancher cluster navigation bar - Nodes highlighted

      5. A list of your cluster’s nodes will appear. If they are still provisioning, they will be labelled with the most recent step in the provisioning sequence:

        Rancher cluster nodes list - provisioning

        When the nodes finish provisioning, the Active label will be displayed:

        Rancher cluster nodes list - active

      6. When your nodes have finished provisioning, click the Cluster item in the navigation bar to navigate back to the dashboard. A summary of the cluster’s resource usage is displayed:

        Rancher cluster dashboard

      Load the Kubectl Command Line

      In addition to managing your cluster via Rancher’s interactive UI, Rancher also provides command-line access to your cluster’s Kubernetes API:

      • From your cluster’s dashboard, click the Launch kubectl button:

        Rancher cluster dashboard - kubectl button highlighted

        A new dialog will appear with a command-line prompt. You are able to use kubectl to interact with your cluster:

        Rancher kubectl web CLI

      • Alternatively, you can use the kubectl CLI from your local computer if you have it installed. From your cluster’s dashboard in Rancher, click on the Kubeconfig File button:

        Rancher cluster dashboard - kubeconfig button highlighted

        A new dialog will appear with the correct kubeconfig for your cluster. Copy the contents of the configuration to a file on your computer. Then, pass it as an option when using the CLI:

        kubectl --kubeconfig /path/to/your/local/kube.config get pods
        

      Rancher Projects

      Rancher introduces an organizational concept called projects. Projects group together Kubernetes namespaces and allows you to perform actions across all namespaces in a project, like adjusting administrative access to them.

      1. To view your cluster’s projects, click on the cluster selection menu in Rancher’s navigation bar, then hover over your cluster in the dropdown menu’s Clusters list:

        Rancher cluster selection menu - list of projects

        A new cluster created through Rancher will have a Default project and a System project.

      2. Options for creating new projects are exposed under the navigation bar’s Projects/Namespaces item:

        Rancher cluster navigation bar - Projects/Namespaces highlighted

        However, this guide will deploy its example app to the Default project.

      3. Navigate to the Default project. Click on the cluster selection menu in Rancher’s navigation bar, then hover over your cluster in the dropdown menu’s Clusters list, and then click on the Default item that appears:

        Rancher cluster selection menu - Default project highlighted

      4. The Workloads view for the project will appear, but it will be empty, as no apps have been deployed yet. Also, note that the items in the navigation bar will change when viewing a project:

        Rancher navigation bar - project mode

      Deploy an App from the Rancher App Library

      Rancher provides a library of apps which offer easy setup through Rancher’s UI. The apps in this curated library are based on existing Helm charts.

      A Helm chart is a popular format for describing Kubernetes resources. Rancher extends the Helm chart format with some additional configuration files, and this extended packaging is referred to as a Rancher chart. The additional information in the Rancher chart format is used to create interactive forms for configuring the app through the Rancher UI.

      Note

      It is possible to enable more app catalogs than just Rancher’s curated library, including a catalog of stable Helm charts. These other apps will not feature Rancher’s easy setup forms and will instead require manual entry of configuration options.

      To test out deploying an app on your new cluster, launch the WordPress app from the Rancher library. This app will also take advantage of Linode’s Block Storage, NodeBalancer, and DNS services (via the CCM and CSI):

      1. From the Default project in your new cluster, click on the Apps item in the navigation bar:

        Rancher project navigation bar - Apps highlighted

      2. The Apps view for your project will appear, but it will show a placeholder image because no apps have been deployed yet. Click on this view’s Launch button.

      3. A list of apps will appear. Scroll down to the WordPress app and click its View Details button:

        WordPress app in Rancher app library catalog

      4. The setup form for the WordPress app will appear. In the WordPress Settings section, enter a username, password, and email for your WordPress admin user:

        Rancher WordPress setup form - WordPress Settings

        Note

        Avoid using symbols in the password you enter, as some symbols can cause syntax errors for this Rancher chart.

      5. In the Database Settings section, enter a password for WordPress’ database user. Then set MariaDB Persistent Volume Enabled to True and select the linode-block-storage option from the Default StorageClass for MariaDB dropdown menu:

        Rancher WordPress setup form - Database Settings

        These settings will result in your database deployment keeping its data in a Linode Block Storage Volume.

        Note

        The default value for the MariaDB Volume Size field is 8GiB, but the minimum size for a Block Storage Volume is 10Gib. The Linode CSI will automatically upgrade any persistent volume claims that are smaller than 10GiB to 10GiB.

      6. In the Services and Load Balancing section, set Expose app using Layer 7 Load Balancer to False, then choose the L4 Balancer option from the WordPress Service Type dropdown menu:

        Rancher WordPress setup form - Services and Load Balancing Settings

        Selecting the L4 Balancer option will result in the creation of a Linode NodeBalancer.

      7. Click the Launch button at the bottom of the form.

      8. You will be directed back to the project’s Apps view, where your new WordPress app will be listed. The listing will show a red bar with the number 2 below it. 2 represents the number of pods in the app, and the red color indicates that they are not available yet.

      9. Click on the name of the app:

        Rancher deployed apps list - WordPress app in middle of provisioning

      10. A detail view for the app will appear. The Workloads section will show the MariaDB and WordPress deployments for your app. They may still be in the middle of provisioning:

        Rancher app detail view - Workloads section

        When the deployments finish provisioning, they will display the Active label and the red bars under the Scale column will turn green.

      11. The Endpoints section displays the address of the NodeBalancer that was created for your app. After your deployments have finished provisioning, click on the HTTP NodeBalancer endpoint:

        Rancher app detail view - NodeBalancer HTTP endpoint highlighted

        Your WordPress site should open in a new browser tab.

      12. Visit the wp-login.php page on your site (e.g. at http://your-nodebalancer-name.newark.nodebalancer.linode.com/wp-login.php). You should be able to login with the WordPress admin username and password you specified earlier in the app’s form.

        Note

        If you view the Volumes and NodeBalancers areas of the Linode Cloud Manager, you should see the new Volume and NodeBalancer that were created for this app. They will have random alphanumeric names like pvc77e0c083490411e9beabf23c916b1.

      Set Up DNS for the WordPress App

      You can currently visit your new app from the NodeBalancer’s generic subdomain. With the Linode CCM, it’s also possible to assign a custom domain or subdomain to your app:

      1. In the detail view for your WordPress app, scroll down to the Services section.

      2. Click on the more options ellipsis for the wordpress-wordpress service, then click on the View/Edit YAML item in the dropdown menu that appears:

        Rancher Services section - View/Edit YAML option highlighted

      3. A YAML editor for the service will appear. Find the annotations section under the metadata sections, then insert this line:

        1
        2
        3
        
        metadata:
          annotations:
            external-dns.alpha.kubernetes.io/hostname: wordpress.example.com

        Replace wordpress.example.com with the address you want to use for your app. As a reminder, example.com needs to exist as a domain zone on your Linode account. If you’re not sure if you’ve inserted the new line in the right location, compare your YAML with this snippet of an updated metadata section.

      4. Click the Save button below the YAML editor.

      5. The Linode CCM will create a DNS record in your domain’s zone and automatically assign the IP of your NodeBalancer to it. If you visit the domain’s zone in the Linode Cloud Manager, the new A record should appear.

      6. It may take some time for Linode’s DNS database to update, so if you don’t see the record show up in the Cloud Manager immediately, try refreshing it after a few minutes.

        After the record becomes visible in the Cloud Manager, it can also take time for the DNS change to propagate to your local ISP. After the DNS change has propagated, you should be able to view your WordPress app by navigating to the address you set up.

      Scaling your Cluster and App

      Rancher makes it easy to scale the number of nodes in your cluster and to scale the number of replica pods in your app’s deployments.

      Scale your Cluster

      Caution

      The example instructions in this section will add nodes to your cluster, which will add further billable services to your account. You can read these instructions without performing them on your own account if you prefer.

      1. Return to the home page by hovering over the Global dropdown menu in the main navigation bar and then clicking the Global menu item:

        Rancher return to the global view

      2. Your cluster will show up on the page that appears. Click on the more options ellipsis corresponding to the cluster and then click on the Edit item from the dropdown menu:

        Rancher global list of clusters - Edit option highlighted

      3. The same form that you completed when creating your cluster will appear. In the Node Pools section, increase the count of your pool:

        Rancher edit cluster form - node pool count highlighted

        Note

        Your example cluster’s nodes all run etcd, so you can only scale the node pool to a count of 1, 3, or 5. If you had a separate node pool for your workloads, you could scale it freely to any count.

      4. Click the Save button at the bottom of the form. You will be redirected to the dashboard for the cluster.

      5. The dashboard will report that the cluster is updating. When the new nodes have finished provisioning and are registered with Kubernetes, the dashboard will show that all components and nodes are responding normally.

      Scale your App

      Rancher also provides an easy way to scale your app’s deployments:

      1. Navigate to the Default project of your cluster:

        Rancher cluster selection menu - Default project highlighted

      2. Click on the Apps item in the navigation bar:

        Rancher project navigation bar - Apps highlighted

      3. Click on the name of the WordPress app:

        Rancher deployed apps list - WordPress app completed provisioning

      4. In the Workloads section, click on the wordpress-wordpress link in the Name column for that deployment:

        Rancher WordPress workloads - deployment name highlighted

      5. A detail view for the deployment will appear. In the Config Scale section at the top, click on the + button to increase the replica count for the deployment by one (to a total of 2):

        Rancher WordPress deployment detail view - config scale highlighted

      6. A second pod will appear in the Pods section on this page, and there will be an Updating label at the top of the page. You may see a series of warning messages about the new pod not being available. Eventually, the new pod will be labelled as Running.

      Set Up GitHub Authentication

      In addition to manually creating users that can access your Rancher application, you can also enable GitHub authentication and then invite GitHub users:

      1. From the Global home page, click on the Security item in the navigation bar and then select Authentication from the dropdown menu:

        Rancher Security navigation bar item - Authentication highlighted

      2. Choose GitHub from the authentication options listed:

        Rancher Authentication page - GitHub option selected

      3. In a new browser window, visit the developer settings of your account on the GitHub website. Click the Register a new application button under the OAuth Apps section.

      4. Fill out the form that appears. Use the values that Rancher lists under the Authentication page that you have open in your original browser window, then click the Register application button:

        Rancher generated GitHub OAuth form values

      5. You will be directed to the detail view for your new OAuth application. Copy the ClientID and Client Secret values displayed on this page. Paste these into the form at the bottom of Rancher’s Authentication page:

        Rancher Authentication page - Client ID and Secret form

      6. Click the Authenticate with GitHub button. A new browser window will appear that asks you to confirm the access request.

      7. Confirm the access request. Rancher will show a new page with further options for controlling access to your Rancher site.

      8. To invite GitHub users to your Rancher site, enter them in the search field in the Site Access section and select the correct user from the search results. Then, click the Save button:

        Rancher Authentication page - search for and add GitHub users

      Removing the Cluster

      To remove the cluster:

      1. Navigate to the Global home page.

      2. Click on the more options ellipsis for your cluster, then select the Delete option from the dropdown menu that appears:

        Rancher global cluster list - delete option highlighted

      3. Confirm in the Linode Cloud Manager that all the Linodes, Volumes, NodeBalancers, and DNS records from the cluster are deleted.

      More Information

      You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

      Find answers, ask questions, and help others.

      This guide is published under a CC BY-ND 4.0 license.



      Source link