Skip to content

Commit 8b94469

Browse files
authored
Merge pull request #263311 from paulopiyo777/nexus-arc-servers
Update public documentation on arc servers addon
2 parents e51e459 + 1067ba3 commit 8b94469

File tree

4 files changed

+39
-184
lines changed

4 files changed

+39
-184
lines changed

articles/operator-nexus/howto-kubernetes-cluster-connect.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ Once you are connected to a cluster via Arc for Kuberentes, you can connect to i
7070

7171
The `az ssh arc` command allows users to remotely access a cluster VM that has been connected to Azure Arc. This method is a secure way to SSH into the cluster node directly from the command line, while in connected mode. Once the cluster VM has been registered with Azure Arc, the `az ssh arc` command can be used to manage the machine remotely, making it a quick and efficient method for remote management.
7272

73-
To use `az arc ssh`, users need to manually connect the cluster VMs to Arc by creating a service principal (SP) with the 'Azure Connected Machine Onboarding' role. For more detailed steps on how to connect an Azure Operator Nexus Kubernetes cluster node to Arc, refer to the [how to guide](./howto-monitor-naks-cluster.md#monitor-nexus-kubernetes-cluster--vm-layer).
74-
7573
1. Set the required variables.
7674

7775
```bash

articles/operator-nexus/howto-monitor-naks-cluster.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The following resources provide you with support:
5353
[!INCLUDE [dcr.sh](./includes/dcr.md)]
5454
- `assign.sh`: use the script to create a policy to associate the DCR with all Arc-enabled servers in a resource group
5555
[!INCLUDE [assign.sh](./includes/assign.md)]
56-
- `install.sh`: Arc-enable Nexus Kubernetes cluster VMs and install Azure Monitoring Agent on each VM
56+
- `install.sh`: Install Azure Monitoring Agent on each VM to collect monitoring data from Azure Virtual Machines.
5757
[!INCLUDE [install.sh](./includes/install.md)]
5858

5959
### Prerequisites-VM
@@ -169,12 +169,13 @@ For convenience, the provided **`assign.sh`** script assigns the built-in policy
169169
./assign.sh
170170
```
171171

172-
#### Connect Arc-enabled servers and install Azure monitoring agent
172+
#### Install Azure monitoring agent
173173

174-
Use the included **`install.sh`** script to Arc-enroll all server VMs that represent the nodes of the Nexus Kubernetes cluster.
175-
This script creates a Kubernetes daemonSet on the Nexus Kubernetes cluster.
176-
It deploys a pod to each cluster node, connecting each VM to Arc-enabled servers and installing the Azure Monitoring Agent (AMA).
174+
Use the included **`install.sh`** which creates a Kubernetes daemonSet on the Nexus Kubernetes cluster.
175+
It deploys a pod to each cluster node and installs the Azure Monitoring Agent (AMA).
177176
The `daemonSet` also includes a liveness probe that monitors the server connection and AMA processes.
177+
> [!NOTE]
178+
> To install Azure Monitoring Agent, you must first Arc connect the Nexus Kubernetes cluster VMs. This process is automated if you are using the latest version bundle. However, if the version bundle you use does not support cluster VM Arc enrollment by default, you will need to upgrade your cluster to the latest version bundle. For more information about the version bundle, please refer [Nexus Kubernetes cluster supported versions](reference-nexus-kubernetes-cluster-supported-versions.md)
178179
179180
1. Set the environment as specified in [Environment Setup](#environment-setup). Set the current `kubeconfig` context for the Nexus Kubernetes cluster VMs.
180181
2. Permit `Kubectl` access to the Nexus Kubernetes cluster.
@@ -191,7 +192,6 @@ kubectl logs <podname>
191192
```
192193

193194
On completion, the system logs the message "Server monitoring configured successfully".
194-
At that point, the Arc-enabled servers appear as resources within the selected resource group.
195195

196196
> [!NOTE]
197197
> Associate these connected servers to the [DCR](#associate-arc-enabled-server-resources-to-dcr).
@@ -277,7 +277,7 @@ Validate the successful deployment of monitoring agents’ enablement on Nexus K
277277
az k8s-extension show --name azuremonitor-containers \
278278
--cluster-name "<Nexus Kubernetes cluster Name>" \
279279
--resource-group "<Nexus Kubernetes cluster Resource Group>" \
280-
--cluster-type conectedClusters
280+
--cluster-type connectedClusters
281281
```
282282

283283
Look for a Provisioning State of "Succeeded" for the extension. The "k8s-extension create" command may have also returned the status.

articles/operator-nexus/includes/install.md

Lines changed: 25 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -261,146 +261,6 @@ spec:
261261
262262
EOF
263263
264-
nsenter -t1 -m -u -n -i tee "\${WORKDIR}"/telemetry/setup_arc_for_servers.py > /dev/null <<EOF
265-
#!/usr/bin/python3
266-
import json
267-
import time
268-
269-
import telemetry_common
270-
271-
272-
def run_connect(logger, arc_config):
273-
logger.info("Connect machine to Azure Arc...")
274-
service_principal_id = arc_config.get("SERVICE_PRINCIPAL_ID")
275-
service_principal_secret = arc_config.get("SERVICE_PRINCIPAL_SECRET")
276-
resource_group = arc_config.get("RESOURCE_GROUP")
277-
tenant_id = arc_config.get("TENANT_ID")
278-
subscription_id = arc_config.get("SUBSCRIPTION_ID")
279-
location = arc_config.get("LOCATION")
280-
connect_cmd = f'azcmagent connect --service-principal-id "{service_principal_id}" --service-principal-secret "{service_principal_secret}" --resource-group "{resource_group}" --tenant-id "{tenant_id}" --subscription-id "{subscription_id}" --location "{location}"'
281-
282-
cloudtype = arc_config.get("CLOUDTYPE")
283-
if cloudtype is not None:
284-
connect_cmd += f' --cloud "{cloudtype}"'
285-
286-
tags = arc_config.get("TAGS")
287-
if tags is not None:
288-
connect_cmd += f' --tags "{tags}"'
289-
290-
correlation_id = arc_config.get("CORRELATION_ID")
291-
if correlation_id is not None:
292-
connect_cmd += f' --correlation-id "{correlation_id}"'
293-
294-
proxy_url = arc_config.get("PROXY_URL")
295-
if proxy_url is not None:
296-
set_proxy_cmd = f'/usr/bin/azcmagent config set proxy.url "{proxy_url}"'
297-
telemetry_common.run_cmd(logger, set_proxy_cmd)
298-
299-
# Hardcoding allowed extensions as these will only vary if NC team adds new extensions
300-
allowed_extensions = "Microsoft.Azure.Monitor/AzureMonitorLinuxAgent,Microsoft.Azure.AzureDefenderForServers/MDE.Linux"
301-
set_extensions_cmd = (
302-
f'/usr/bin/azcmagent config set extensions.allowlist "{allowed_extensions}"'
303-
)
304-
telemetry_common.run_cmd(logger, set_extensions_cmd)
305-
306-
telemetry_common.az_login(logger, arc_config)
307-
logger.info("Connecting machine to Azure Arc...")
308-
309-
try:
310-
telemetry_common.run_cmd(logger, connect_cmd)
311-
except:
312-
logger.info("Trying to connect machine to Azure Arc...")
313-
finally:
314-
telemetry_common.az_logout(logger)
315-
316-
317-
def run_disconnect(logger, arc_config):
318-
logger.info("Disconnect machine from Azure Arc...")
319-
service_principal_id = arc_config.get("SERVICE_PRINCIPAL_ID")
320-
service_principal_secret = arc_config.get("SERVICE_PRINCIPAL_SECRET")
321-
322-
cmd = f'/usr/bin/azcmagent disconnect --service-principal-id "{service_principal_id}" --service-principal-secret "{service_principal_secret}"'
323-
324-
telemetry_common.az_login(logger, arc_config)
325-
326-
try:
327-
telemetry_common.run_cmd(logger, cmd)
328-
except:
329-
logger.info("Trying to disconnect machine from Azure Arc...")
330-
finally:
331-
telemetry_common.az_logout(logger)
332-
333-
334-
def arc_enrollment(logger, arc_config):
335-
logger.info("Executing Arc enrollment...")
336-
337-
telemetry_common.az_cli_cm_ext_install(logger, arc_config)
338-
339-
# Get connected machine properties
340-
cm_provisioning_state, cm_status = telemetry_common.get_cm_properties(
341-
logger, arc_config
342-
)
343-
344-
if (
345-
cm_provisioning_state == telemetry_common.AgentryResult.SUCCEEDED
346-
and cm_status == telemetry_common.AgentryResult.CONNECTED
347-
):
348-
logger.info(telemetry_common.OnboardingMessage.COMPLETED)
349-
return True
350-
elif cm_provisioning_state in [
351-
telemetry_common.AgentryResult.FAILED,
352-
telemetry_common.AgentryResult.DISCONNECTED,
353-
]:
354-
run_disconnect(logger, arc_config)
355-
logger.warning(telemetry_common.OnboardingMessage.STILL_TRYING)
356-
return False
357-
elif cm_provisioning_state == telemetry_common.AgentryResult.CREATING:
358-
logger.warning(telemetry_common.OnboardingMessage.STILL_CREATING)
359-
return False
360-
else:
361-
run_connect(logger, arc_config)
362-
logger.warning(telemetry_common.OnboardingMessage.STILL_TRYING)
363-
return False
364-
365-
366-
def main():
367-
timeout = 300 # TODO: increase when executed via systemd unit
368-
start_time = time.time()
369-
end_time = start_time + timeout
370-
371-
config_file = telemetry_common.arc_config_file
372-
373-
logger = telemetry_common.get_logger(__name__)
374-
375-
logger.info("Running setup_arc_for_servers.py...")
376-
377-
if config_file is None:
378-
raise Exception("config file is expected")
379-
380-
arc_config = {}
381-
382-
with open(config_file, "r") as file:
383-
arc_config = json.load(file)
384-
385-
arc_enrolled = False
386-
387-
while time.time() < end_time:
388-
logger.info("Arc enrolling the server...")
389-
try:
390-
arc_enrolled = arc_enrollment(logger, arc_config)
391-
except Exception as e:
392-
logger.error(f"Could not arc enroll server: {e}")
393-
if arc_enrolled:
394-
break
395-
logger.info("Sleeping 30s...") # retry for Azure info
396-
time.sleep(30)
397-
398-
399-
if __name__ == "__main__":
400-
main()
401-
402-
EOF
403-
404264
nsenter -t1 -m -u -n -i tee "\${WORKDIR}"/telemetry/setup_azure_monitor_agent.py > /dev/null <<EOF
405265
#!/usr/bin/python3
406266
import json
@@ -467,35 +327,35 @@ spec:
467327
468328
# Get connected machine properties
469329
cm_provisioning_state, cm_status = telemetry_common.get_cm_properties(
470-
logger, ama_config
330+
logger, ama_config
471331
)
472332
473333
if (
474-
cm_provisioning_state == telemetry_common.AgentryResult.SUCCEEDED
475-
and cm_status == telemetry_common.AgentryResult.CONNECTED
334+
cm_provisioning_state == telemetry_common.AgentryResult.SUCCEEDED
335+
and cm_status == telemetry_common.AgentryResult.CONNECTED
476336
):
477-
# Get AzureMonitorLinuxAgent extension status
478-
ext_provisioning_state = telemetry_common.get_cm_extension_state(
479-
logger, ama_config, "AzureMonitorLinuxAgent"
480-
)
481-
482-
if ext_provisioning_state == telemetry_common.AgentryResult.SUCCEEDED:
483-
logger.info(telemetry_common.OnboardingMessage.COMPLETED)
484-
return True
485-
elif ext_provisioning_state == telemetry_common.AgentryResult.FAILED:
486-
run_uninstall(logger, ama_config)
487-
logger.warning(telemetry_common.OnboardingMessage.STILL_TRYING)
488-
return False
489-
elif ext_provisioning_state == telemetry_common.AgentryResult.CREATING:
490-
logger.warning(telemetry_common.OnboardingMessage.STILL_CREATING)
491-
return False
492-
else:
493-
run_install(logger, ama_config)
494-
logger.warning(telemetry_common.OnboardingMessage.STILL_TRYING)
495-
return False
496-
else:
497-
logger.error("Server not arc enrolled, enroll the server and retry")
337+
# Get AzureMonitorLinuxAgent extension status
338+
ext_provisioning_state = telemetry_common.get_cm_extension_state(
339+
logger, ama_config, "AzureMonitorLinuxAgent"
340+
)
341+
342+
if ext_provisioning_state == telemetry_common.AgentryResult.SUCCEEDED:
343+
logger.info(telemetry_common.OnboardingMessage.COMPLETED)
344+
return True
345+
elif ext_provisioning_state == telemetry_common.AgentryResult.FAILED:
346+
run_uninstall(logger, ama_config)
347+
logger.warning(telemetry_common.OnboardingMessage.STILL_TRYING)
498348
return False
349+
elif ext_provisioning_state == telemetry_common.AgentryResult.CREATING:
350+
logger.warning(telemetry_common.OnboardingMessage.STILL_CREATING)
351+
return False
352+
else:
353+
run_install(logger, ama_config)
354+
logger.warning(telemetry_common.OnboardingMessage.STILL_TRYING)
355+
return False
356+
else:
357+
logger.error("Server not arc enrolled, enroll the server and retry")
358+
return False
499359
500360
501361
def main():
@@ -543,16 +403,6 @@ spec:
543403
544404
echo "{\"VERSION\": \"\${VERSION}\", \"SUBSCRIPTION_ID\": \"\${SUBSCRIPTION_ID}\", \"SERVICE_PRINCIPAL_ID\": \"\${SERVICE_PRINCIPAL_ID}\", \"SERVICE_PRINCIPAL_SECRET\": \"\${SERVICE_PRINCIPAL_SECRET}\", \"RESOURCE_GROUP\": \"\${RESOURCE_GROUP}\", \"TENANT_ID\": \"\${TENANT_ID}\", \"LOCATION\": \"\${LOCATION}\", \"PROXY_URL\": \"\${PROXY_URL}\", \"CONNECTEDMACHINE_AZCLI_VERSION\": \"\${CONNECTEDMACHINE_AZCLI_VERSION}\"}" > "\${WORKDIR}"/telemetry/arc-connect.json
545405
546-
echo "Connecting machine to Azure Arc..."
547-
/usr/bin/python3 "\${WORKDIR}"/telemetry/setup_arc_for_servers.py > "\${WORKDIR}"/setup_arc_for_servers.out
548-
cat "\${WORKDIR}"/setup_arc_for_servers.out
549-
if grep "Could not arc enroll server" "\${WORKDIR}"/setup_arc_for_servers.out > /dev/null; then
550-
exit 1
551-
fi
552-
553-
/usr/bin/azcmagent config set incomingconnections.ports 22
554-
/usr/bin/azcmagent config set extensions.allowlist Microsoft.Azure.Monitor/AzureMonitorLinuxAgent,Microsoft.Azure.AzureDefenderForServers/MDE.Linux,Microsoft.Azure.ActiveDirectory/AADSSHLoginForLinux
555-
556406
if [ "\${INSTALL_AZURE_MONITOR_AGENT}" = "true" ]; then
557407
echo "Installing Azure Monitor agent..."
558408
/usr/bin/python3 "\${WORKDIR}"/telemetry/setup_azure_monitor_agent.py > "\${WORKDIR}"/setup_azure_monitor_agent.out
@@ -642,4 +492,4 @@ CONNECTEDMACHINE_AZCLI_VERSION="${CONNECTEDMACHINE_AZCLI_VERSION:-"0.6.0"}"
642492

643493
create_secret
644494
create_daemonset
645-
```
495+
```

0 commit comments

Comments
 (0)