Questo contenuto non è disponibile nella lingua selezionata.
Chapter 24. Configuring for Azure
You can configure OpenShift Container Platform to use Microsoft Azure load balancers and disks for persistent application data.
24.1. Before you begin Copia collegamentoCollegamento copiato negli appunti!
24.1.1. Configuring authorization for Microsoft Azure Copia collegamentoCollegamento copiato negli appunti!
Azure roles
Configuring Microsoft Azure for OpenShift Container Platform requires the following Microsoft Azure role:
Contributor | To create and manage all types of Microsoft Azure resources. |
See the Classic subscription administrator roles vs. Azure RBAC roles vs. Azure AD administrator roles documentation for more information.
Permissions
Configuring Microsoft Azure for OpenShift Container Platform requires a service principal, which allows the creation and management of Kubernetes service load balancers and disks for persistent storage. The service principal values are defined at installation time and deployed to the Azure configuration file, located at /etc/origin/cloudprovider/azure.conf
on OpenShift Container Platform master and node hosts.
Procedure
Using the Azure CLI, obtain the account subscription ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The subscription ID to use to create the new permissions.
Create the service principal with the Microsoft Azure role of contributor and with the scope of the Microsoft Azure subscription and the resource group. Record the output of these values to be used when defining the inventory. Use the
<subscription>
value from the previous step in place of the value below:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
24.1.2. Configuring Microsoft Azure objects Copia collegamentoCollegamento copiato negli appunti!
Integrating OpenShift Container Platform with Microsoft Azure requires the following components or services to create a highly-available and full-featured environment.
To ensure that the appropriate amount of instances can be launched, request an increase in CPU quota from Microsoft before creating instances.
- A resource group
- Resource groups contain all Microsoft Azure components for a deployment, including networking, load balancers, virtual machines, and DNS. Quotas and permissions can be applied to resources groups to control and manage resources deployed on Microsoft Azure. Resource groups are created and defined per geographic region. All resources created for an OpenShift Container Platform environment should be within the same geographic region and within the same resource group.
See Azure Resource Manager overview for more information.
- Azure Virtual Networks
- Azure Virtual Networks are used to isolate Azure cloud networks from one another. Instances and load balancers use the virtual network to allow communication with each other and to and from the Internet. The virtual network allows for the creation of one or many subnets to be used by components within a resource group. You can also connect virtual networks to various VPN services, allowing communication with on-premise services.
See What is Azure Virtual Network? for more information.
- Azure DNS
- Azure offers a managed DNS service that provides internal and Internet-accessible host name and load balancer resolution. The reference environment uses a DNS zone to host three DNS A records to allow for mapping of public IPs to OpenShift Container Platform resources and a bastion.
See What is Azure DNS? for more information.
- Load balancing
- Azure load balancers allow network connectivity for scaling and high availability of services running on virtual machines within the Azure environment.
See What is Azure Load Balancer?
- Storage Account
-
Storage Accounts allow for resources, such as virtual machines, to access the different type of storage components offered by Microsoft Azure. During installation, the storage account defines the location of the object-based
blob
storage used for the OpenShift Container Platform registry.
See Introduction to Azure Storage for more information, or the Configuring the OpenShift Container Platform registry for Microsoft Azure section for steps to create the storage account for the registry.
- Service Principal
- Azure offers the ability to create service accounts, which access, manage, or create components within Azure. The service account grants API access to specific services. For example, a service principal allows Kubernetes or OpenShift Container Platform instances to request persistent storage and load balancers. Service principals allow for granular access to be given to instances or users for specific functions.
See Application and service principal objects in Azure Active Directory for more information.
- Availability Sets
- Availability sets ensure that the deployed VMs are distributed across multiple isolated hardware nodes in a cluster. The distribution helps to ensure that when maintenance on the cloud provider hardware occurs, instances will not all run on one specific node.
You should segment instances to different availability sets based on their role. For example, one availability set containing three master hosts, one availability set containing infrastructure hosts, and one availability set containing application hosts. This allows for segmentation and the ability to use external load balancers within OpenShift Container Platform.
See Manage the availability of Linux virtual machines for more information.
- Network Security Groups
- Network Security Groups (NSGs) provide a list of rules to either allow or deny traffic to resources deployed within an Azure Virtual Network. NSGs use numeric priority values and rules to define what items are allowed to communicate with each other. You can place restrictions on where communication is allowed to occur, such as within only the virtual network, from load balancers, or from everywhere.
Priority values allow for administrators to grant granular values on the order in which port communication is allowed or not allowed to occur.
See Plan virtual networks for more information.
- Instances sizes
- A successful OpenShift Container Platform environment requires some minimum hardware requirements.
See the Minimum Hadware Requirements section in the OpenShift Container Platform documentation or Sizes for Cloud Services for more information.
24.2. The Azure configuration file Copia collegamentoCollegamento copiato negli appunti!
Configuring OpenShift Container Platform for Azure requires the /etc/azure/azure.conf file, on each node host.
If the file does not exist, you can create it.
- 1
- The AAD tenant ID for the subscription that the cluster is deployed in.
- 2
- The Azure subscription ID that the cluster is deployed in.
- 3
- The client ID for an AAD application with RBAC access to talk to Azure RM APIs.
- 4
- The client secret for an AAD application with RBAC access to talk to Azure RM APIs.
- 5
- Ensure this is the same as tenant ID (optional).
- 6
- The Azure Resource Group name that the Azure VM belongs to.
- 7
- The specific cloud region. For example,
AzurePublicCloud
. - 8
- The compact style Azure region. For example,
southeastasia
(optional). - 9
- Virtual network containing instances and used when creating load balancers.
- 10
- Security group name associated with instances and load balancers.
- 11
- Availability set to use when creating resources such as load balancers (optional).
The NIC used for accessing the instance must have an internal-dns-name
set or the node will not be able to rejoin the cluster, display build logs to the console, and will cause oc rsh
to not work correctly.
24.3. Example inventory for OpenShift Container Platform on Microsoft Azure Copia collegamentoCollegamento copiato negli appunti!
The example inventory below assumes that the following items have been created:
- A resource group
- An Azure virtual network
- One or more network security groups that contain the required OpenShift Container Platform ports
- A storage account
- A service principal
- Two load balancers
- Two or more DNS entries for the routers and for the OpenShift Container Platform web console
- Three Availability Sets
- Three master instances
- Three infrastructure instances
- One or more application instances
The inventory below uses the default storageclass
to create persistent volumes to be used by the metrics, logging, and service catalog components managed by a service principal. The registry uses Microsoft Azure blob storage.
If the Microsoft Azure instances use managed disks, provide the following variable in the inventory:
openshift_storageclass_parameters={'kind': 'managed', 'storageaccounttype': 'Premium_LRS'}
or
openshift_storageclass_parameters={'kind': 'managed', 'storageaccounttype': 'Standard_LRS'}
This ensures the storageclass
creates the correct disk type for PVs
as it relates to the instances deployed. If unmanaged disks are used, the storageclass
will use the shared
parameter allowing for unmanged disks to be created for PVs
.
- 1 2
- If you use a container registry that requires authentication, such as the default container image registry, specify the credentials for that account. See Accessing and Configuring the Red Hat Registry.
24.4. Configuring OpenShift Container Platform for Microsoft Azure Copia collegamentoCollegamento copiato negli appunti!
You can configure OpenShift Container Platform for Microsoft Azure in two ways:
24.4.1. Configuring OpenShift Container Platform for Azure by using Ansible Copia collegamentoCollegamento copiato negli appunti!
You can configure OpenShift Container Platform for Azure at installation time.
Add the following to the Ansible inventory file located at /etc/ansible/hosts by default to configure your OpenShift Container Platform environment for Microsoft Azure:
- 1
- The app ID value for the service principal.
- 2
- The secret containing the password for the service principal.
- 3
- The tenant in which the service principal exists.
- 4
- The subscription used by the service principal.
- 5
- The resource group where the service account exists.
- 6
- The Microsoft Azure location where the resource group exists.
Installing with Ansible also creates and configures the following files to fit your Microsoft Azure environment:
- /etc/origin/cloudprovider/azure.conf
- /etc/origin/master/master-config.yaml
- /etc/origin/node/node-config.yaml
24.4.2. Manually configuring OpenShift Container Platform for Microsoft Azure Copia collegamentoCollegamento copiato negli appunti!
24.4.2.1. Manually configuring master hosts for Microsoft Azure Copia collegamentoCollegamento copiato negli appunti!
Perform the following on all master hosts.
Procedure
Edit the master configuration file located at
/etc/origin/master/master-config.yaml
by default on all masters and update the contents of theapiServerArguments
andcontrollerArguments
sections:Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantWhen triggering a containerized installation, only the /etc/origin and /var/lib/origin directories are mounted to the master and node container. Therefore, ensure master-config.yaml is in the /etc/origin/master directory instead of /etc/.
When you configure OpenShift Container Platform for Microsoft Azure using Ansible, the
/etc/origin/cloudprovider/azure.conf
file is created automatically. Because you are manually configuring OpenShift Container Platform for Microsoft Azure, you must create the file on all node instances and include the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The tenant in which the service principal exists.
- 2
- The subscription used by the service principal.
- 3
- The appID value for the service principal.
- 4
- The secret containing the password for the service principal.
- 5
- The tenant in which the service principal exists.
- 6
- The resource group where the service account exists.
- 7
- The Microsoft Azure location where the resource group exists.
Restart the OpenShift Container Platform master services:
master-restart api master-restart controllers
# master-restart api # master-restart controllers
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
24.4.2.2. Manually configuring node hosts for Microsoft Azure Copia collegamentoCollegamento copiato negli appunti!
Perform the following on all node hosts.
Procedure
Edit the appropriate node configuration map and update the contents of the
kubeletArguments
section:kubeletArguments: cloud-provider: - "azure" cloud-config: - "/etc/origin/cloudprovider/azure.conf"
kubeletArguments: cloud-provider: - "azure" cloud-config: - "/etc/origin/cloudprovider/azure.conf"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantThe NIC used for accessing the instance must have an internal DNS name set or the node will not be able to rejoin the cluster, display build logs to the console, and will cause
oc rsh
to not work correctly.Restart the OpenShift Container Platform services on all nodes:
systemctl restart atomic-openshift-node
# systemctl restart atomic-openshift-node
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
24.4.3. Configuring the OpenShift Container Platform registry for Microsoft Azure Copia collegamentoCollegamento copiato negli appunti!
Microsoft Azure provides object cloud storage that OpenShift Container Platform can use to store container images using the OpenShift Container Platform container image registry.
For more information, see Cloud Storage in the Azure documentation.
You can configure the registry either using Ansible or manually by configuring the registry configuration file.
Prerequisites
You must create a storage account to host the registry images before installation. The following command creates a storage account which is used during installation for image storage:
You can use Microsoft Azure blob storage for storing container images. The OpenShift Container Platform registry uses blob storage to allow for the registry to grow dynamically in size without the need for intervention from an administrator.
Create an Azure storage account:
az storage account create --name <account_name> \ --resource-group <resource_group> \ --location <location> \ --sku Standard_LRS
az storage account create --name <account_name> \ --resource-group <resource_group> \ --location <location> \ --sku Standard_LRS
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This creates an account key. To view the account key:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Only one account key value is required for the configuration of the OpenShift Container Platform registry.
Option 1: Configuring the OpenShift Container Platform registry for Azure using Ansible
Procedure
Configure the Ansible inventory for the registry to use the storage account:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Option 2: Manually configuring OpenShift Container Platform registry for Microsoft Azure
To use Microsoft Azure object storage, edit the registry’s configuration file and mount to the registry pod.
Procedure
Export the current config.yml:
oc get secret registry-config \ -o jsonpath='{.data.config\.yml}' -n default | base64 -d \ >> config.yml.old
$ oc get secret registry-config \ -o jsonpath='{.data.config\.yml}' -n default | base64 -d \ >> config.yml.old
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new configuration file from the old config.yml:
cp config.yml.old config.yml
$ cp config.yml.old config.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the file to include the Azure parameters:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the
registry-config
secret:oc delete secret registry-config -n default
$ oc delete secret registry-config -n default
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Recreate the secret to reference the updated configuration file:
oc create secret generic registry-config \ --from-file=config.yml -n default
$ oc create secret generic registry-config \ --from-file=config.yml -n default
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Redeploy the registry to read the updated configuration:
oc rollout latest docker-registry -n default
$ oc rollout latest docker-registry -n default
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verifying the registry is using blob object storage
To verify if the registry is using Microsoft Azure blob storage:
Procedure
After a successful registry deployment, the registry
deploymentconfig
will always show that the registry is using anemptydir
instead of Microsoft Azure blob storage:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The temporary directory that shares a pod’s lifetime.
Check if the /registry mount point is empty. This is the volume Microsoft Azure storage will use:
oc exec \ $(oc get pod -l deploymentconfig=docker-registry \ -o=jsonpath='{.items[0].metadata.name}') -i -t -- ls -l /registry
$ oc exec \ $(oc get pod -l deploymentconfig=docker-registry \ -o=jsonpath='{.items[0].metadata.name}') -i -t -- ls -l /registry total 0
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If it is empty, it is because the Microsoft Azure blob configuration is performed in the
registry-config
secret:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The installer creates a config.yml file with the desired configuration using the extended registry capabilities as seen in Storage in the installation documentation. To view the configuration file, including the
storage
section where the storage bucket configuration is stored:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Or you can view the secret:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
If using an emptyDir
volume, the /registry
mountpoint looks like the following:
24.4.4. Configuring OpenShift Container Platform to use Microsoft Azure storage Copia collegamentoCollegamento copiato negli appunti!
OpenShift Container Platform can use Microsoft Azure storage using persistent volumes mechanisms. OpenShift Container Platform creates the disk in the resource group and attaches the disk to the correct instance.
Procedure
The following
storageclass
is created when you configure the Azure cloud provider at installation using theopenshift_cloudprovider_kind=azure
andopenshift_cloud_provider_azure
variables in the Ansible inventory:Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you did not use Ansible to enable OpenShift Container Platform and Microsoft Azure integration, you can create the
storageclass
manually. See the Dynamic provisioning and creating storage classes section for more information.-
Currently, the default
storageclass
kind isshared
which means that the Microsoft Azure instances must use unmanaged disks. You can optionally modify this by allowing instances to use managed disks by providing theopenshift_storageclass_parameters={'kind': 'Managed', 'storageaccounttype': 'Premium_LRS'}
oropenshift_storageclass_parameters={'kind': 'Managed', 'storageaccounttype': 'Standard_LRS'}
variables in the Ansible inventory file at installation.
Microsoft Azure disks are ReadWriteOnce
access mode, which means the volume can be mounted as read-write by a single node. See the Access modes section of the Architecture guide for more information.
24.4.5. About Red Hat OpenShift Container Storage Copia collegamentoCollegamento copiato negli appunti!
Red Hat OpenShift Container Storage (RHOCS) is a provider of agnostic persistent storage for OpenShift Container Platform either in-house or in hybrid clouds. As a Red Hat storage solution, RHOCS is completely integrated with OpenShift Container Platform for deployment, management, and monitoring regardless if it is installed on OpenShift Container Platform (converged) or with OpenShift Container Platform (independent). OpenShift Container Storage is not limited to a single availability zone or node, which makes it likely to survive an outage. You can find complete instructions for using RHOCS in the RHOCS3.11 Deployment Guide.
24.5. Using the Microsoft Azure external load balancer as a service Copia collegamentoCollegamento copiato negli appunti!
OpenShift Container Platform can leverage the Microsoft Azure load balancer by exposing services externally using a LoadBalancer
service. OpenShift Container Platform creates the load balancer in Microsoft Azure and creates the proper firewall rules.
Currently, a bug causes extra variables to be included in the Microsoft Azure infrastructure when using it as a cloud provider and when using it as an external load balancer. See the following for more information:
Prerequisites
Ensure the the Azure configuration file located at /etc/origin/cloudprovider/azure.conf is correctly configured with the appropriate objects. See the Manually configuring OpenShift Container Platform for Microsoft Azure section for an example /etc/origin/cloudprovider/azure.conf file.
Once the values are added, restart the OpenShift Container Platform services on all hosts:
systemctl restart atomic-openshift-node master-restart api master-restart controllers
# systemctl restart atomic-openshift-node
# master-restart api
# master-restart controllers
24.5.1. Deploying a sample application using a load balancer Copia collegamentoCollegamento copiato negli appunti!
Procedure
Create a new application:
oc new-app openshift/hello-openshift
$ oc new-app openshift/hello-openshift
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Expose the load balancer service:
oc expose dc hello-openshift --name='hello-openshift-external' --type='LoadBalancer'
$ oc expose dc hello-openshift --name='hello-openshift-external' --type='LoadBalancer'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This creates a
Loadbalancer
service similar to the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the service has been created:
oc get svc
$ oc get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-openshift ClusterIP 172.30.223.255 <none> 8080/TCP,8888/TCP 1m hello-openshift-external LoadBalancer 172.30.99.54 40.121.42.180 8080:30714/TCP,8888:30122/TCP 4m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
LoadBalancer
type andExternal-IP
fields indicate that the service is using Microsoft Azure load balancers to expose the application.
This creates the following required objects in the Azure infrastructure:
A load balancer:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
To verify that the load balancer is properly configured, run the following from an external host:
curl 40.121.42.180:8080
$ curl 40.121.42.180:8080
Hello OpenShift!
- 1
- Replace with the values from the
EXTERNAL-IP
verification step above as well as the port number.