

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# `AWSSupport-TroubleshootEKSNetwork`
<a name="automation-awssupport-troubleshooteksnetwork"></a>

## Description
<a name="automation-awssupport-troubleshooteksnetwork-description"></a>

Il `AWSSupport-TroubleshootEKSNetwork` runbook consente di risolvere i problemi di connettività di rete nei contenitori in esecuzione nei cluster Amazon Elastic Kubernetes Service (Amazon EKS). Il runbook raccoglie statistiche di calcolo e di rete dalla sorgente del traffico e dalla destinazione, a seconda del tipo di destinazione.

## Come funziona
<a name="automation-awssupport-troubleshooteksnetwork-how-it-works"></a>

Usa questo runbook per risolvere i problemi di connettività verso i seguenti tipi di destinazione:
+ **POD**: un altro pod. Kubernetes
+ **SERVIZIO**: Un Kubernetes servizio.
+ **IP**: un IPv4/IPv6 indirizzo, interno o esterno al cluster o Amazon VPC.
+ **DNS**: nome di dominio, interno o esterno al cluster o Amazon VPC.

**Importante**  
Oltre alle seguenti autorizzazioni IAM, AutomationAssumeRole devono avere accesso ai cluster Amazon EKS utilizzando i metodi di accesso alle API Amazon EKS [ supportati. ](https://docs.aws.amazon.com//eks/latest/userguide/grant-k8s-access.html) Per i cluster che utilizzano voci di accesso, la policy di `AmazonEKSViewPolicy` accesso è la policy minima richiesta.

 [Esegui questa automazione (console) ](https://console.aws.amazon.com/systems-manager/automation/execute/AWSSupport-TroubleshootEKSNetwork) 

## Autorizzazioni IAM richieste
<a name="automation-awssupport-troubleshooteksnetwork-permissions"></a>

Il `AutomationAssumeRole` parametro richiede le seguenti azioni per utilizzare correttamente il runbook.

Questo runbook esegue i runbook secondari `AWSSupport-SetupK8sApiProxyForEKS` e i runbook `AWSSupport-CollectEKSLinuxNodeStatistics` secondari con lo stesso ruolo. `AutomationAssumeRole`È necessario consentire le seguenti azioni per i runbook principale e secondario:
+ `cloudformation:CreateStack`
+ `cloudformation:DeleteStack`
+ `cloudformation:DescribeStackResources`
+ `cloudformation:DescribeStacks`
+ `cloudformation:UpdateStack`
+ `ec2:CreateNetworkInterface`
+ `ec2:DeleteNetworkInterface`
+ `ec2:DescribeInstances`
+ `ec2:DescribeNetworkInterfaces`
+ `ec2:DescribeRegions`
+ `ec2:DescribeRouteTables`
+ `ec2:DescribeSecurityGroups`
+ `ec2:DescribeSubnets`
+ `ec2:DescribeVpcPeeringConnections`
+ `ec2:DescribeVpcs`
+ `eks:DescribeCluster`
+ `eks:DescribeFargateProfile`
+ `iam:AttachRolePolicy`
+ `iam:CreateRole`
+ `iam:DeleteRole`
+ `iam:DeleteRolePolicy`
+ `iam:DetachRolePolicy`
+ `iam:GetRole`
+ `iam:PassRole`
+ `iam:PutRolePolicy`
+ `iam:TagRole`
+ `iam:UntagRole`
+ `lambda:CreateFunction`
+ `lambda:DeleteFunction`
+ `lambda:GetFunction`
+ `lambda:InvokeFunction`
+ `lambda:ListTags`
+ `lambda:TagResource`
+ `lambda:UntagResource`
+ `lambda:UpdateFunctionCode`
+ `lambda:UpdateFunctionConfiguration`
+ `logs:CreateLogGroup`
+ `logs:CreateLogStream`
+ `logs:DeleteLogGroup`
+ `logs:DescribeLogGroups`
+ `logs:DescribeLogStreams`
+ `logs:ListTagsForResource`
+ `logs:PutLogEvents`
+ `logs:PutRetentionPolicy`
+ `logs:TagResource`
+ `logs:UntagResource`
+ `s3:GetBucketLocation`
+ `s3:GetObject`
+ `s3:PutObject`
+ `ssm:DescribeAutomationExecutions`
+ `ssm:DescribeAutomationStepExecutions`
+ `ssm:DescribeDocument`
+ `ssm:DescribeInstanceInformation`
+ `ssm:GetAutomationExecution`
+ `ssm:GetCommandInvocation`
+ `ssm:GetDocument`
+ `ssm:ListCommands`
+ `ssm:SendCommand`
+ `ssm:StartAutomationExecution`
+ `sts:GetCallerIdentity`
+ `tag:GetResources`
+ `tag:TagResources`

La seguente politica di esempio mostra le autorizzazioni con privilegi minimi richieste per. `AutomationAssumeRole` Sostituisci`REGION`,`ACCOUNTID`, `SOURCE_CLUSTER_NAME``DESTINATION_CLUSTER_NAME`, e `S3_BUCKET_NAME` con i tuoi valori:

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "EKSClusterAccess",
            "Effect": "Allow",
            "Action": "eks:DescribeCluster",
            "Resource": [
                "arn:aws:eks:{{REGION}}:{{ACCOUNTID}}:cluster/{{SOURCE_CLUSTER_NAME}}",
                "arn:aws:eks:{{REGION}}:{{ACCOUNTID}}:cluster/{{DESTINATION_CLUSTER_NAME}}"
            ]
        },
        {
            "Sid": "EKSFargateProfileAccess",
            "Effect": "Allow",
            "Action": "eks:DescribeFargateProfile",
            "Resource": [
                "arn:aws:eks:{{REGION}}:{{ACCOUNTID}}:fargateprofile/{{SOURCE_CLUSTER_NAME}}/*",
                "arn:aws:eks:{{REGION}}:{{ACCOUNTID}}:fargateprofile/{{DESTINATION_CLUSTER_NAME}}/*"
            ]
        },
        {
            "Sid": "EC2DescribePermissions",
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeInstances",
                "ec2:DescribeRegions",
                "ec2:DescribeRouteTables",
                "ec2:DescribeVpcs",
                "ec2:DescribeVpcPeeringConnections",
                "ec2:DescribeSubnets"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "aws:RequestedRegion": "{{REGION}}"
                }
            }
        },
        {
            "Sid": "SSMAutomationExecution",
            "Effect": "Allow",
            "Action": [
                "ssm:StartAutomationExecution",
                "ssm:GetAutomationExecution",
                "ssm:DescribeAutomationExecutions",
                "ssm:DescribeAutomationStepExecutions"
            ],
            "Resource": "arn:aws:ssm:{{REGION}}:{{ACCOUNTID}}:automation-execution/*"
        },
        {
            "Sid": "SSMDocumentAccess",
            "Effect": "Allow",
            "Action": [
                "ssm:DescribeDocument",
                "ssm:GetDocument"
            ],
            "Resource": [
                "arn:aws:ssm:{{REGION}}:{{ACCOUNTID}}:document/AWSSupport-TroubleshootEKSNetwork",
                "arn:aws:ssm:{{REGION}}:{{ACCOUNTID}}:document/AWSSupport-SetupK8sApiProxyForEKS",
                "arn:aws:ssm:{{REGION}}:{{ACCOUNTID}}:document/AWSSupport-CollectEKSLinuxNodeStatistics",
                "arn:aws:ssm:{{REGION}}:*:document/AWS-RunShellScript"
            ]
        },
        {
            "Sid": "SSMRunCommandOnNodes",
            "Effect": "Allow",
            "Action": [
                "ssm:SendCommand",
                "ssm:GetCommandInvocation"
            ],
            "Resource": [
                "arn:aws:ec2:{{REGION}}:{{ACCOUNTID}}:instance/*",
                "arn:aws:ssm:{{REGION}}:*:document/AWS-RunShellScript"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/eks:cluster-name": [
                        "{{SOURCE_CLUSTER_NAME}}",
                        "{{DESTINATION_CLUSTER_NAME}}"
                    ]
                }
            }
        },
        {
            "Sid": "S3TroubleshootingAssets",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": "arn:aws:s3:::{{S3_BUCKET_NAME}}/AWSSupport-CollectEKSLinuxNodeStatistics/*"
        },
        {
            "Sid": "S3BucketLocation",
            "Effect": "Allow",
            "Action": "s3:GetBucketLocation",
            "Resource": "arn:aws:s3:::{{S3_BUCKET_NAME}}"
        },
        {
            "Sid": "LambdaK8sProxyManagement",
            "Effect": "Allow",
            "Action": [
                "lambda:CreateFunction",
                "lambda:DeleteFunction",
                "lambda:GetFunction",
                "lambda:InvokeFunction",
                "lambda:UpdateFunctionCode",
                "lambda:UpdateFunctionConfiguration"
            ],
            "Resource": "arn:aws:lambda:{{REGION}}:{{ACCOUNTID}}:function:Automation-K8sProxy-*"
        },
        {
            "Sid": "CloudFormationK8sProxyStack",
            "Effect": "Allow",
            "Action": [
                "cloudformation:CreateStack",
                "cloudformation:DeleteStack",
                "cloudformation:DescribeStacks",
                "cloudformation:DescribeStackResources"
            ],
            "Resource": "arn:aws:cloudformation:{{REGION}}:{{ACCOUNTID}}:stack/AWSSupport-SetupK8sApiProxyForEKS-*/*"
        },
        {
            "Sid": "IAMForK8sProxyLambdaRole",
            "Effect": "Allow",
            "Action": [
                "iam:CreateRole",
                "iam:DeleteRole",
                "iam:GetRole",
                "iam:AttachRolePolicy",
                "iam:DetachRolePolicy",
                "iam:PutRolePolicy",
                "iam:DeleteRolePolicy"
            ],
            "Resource": "arn:aws:iam::{{ACCOUNTID}}:role/Automation-K8sProxy-Role-*"
        },
        {
            "Sid": "IAMPassRoleToLambda",
            "Effect": "Allow",
            "Action": "iam:PassRole",
            "Resource": "arn:aws:iam::{{ACCOUNTID}}:role/Automation-K8sProxy-Role-*",
            "Condition": {
                "StringEquals": {
                    "iam:PassedToService": "lambda.amazonaws.com"
                }
            }
        },
        {
            "Sid": "CloudWatchLogsForK8sProxy",
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents",
                "logs:DeleteLogGroup"
            ],
            "Resource": "arn:aws:logs:{{REGION}}:{{ACCOUNTID}}:log-group:/aws/lambda/Automation-K8sProxy-*"
        },
        {
            "Sid": "ResourceTaggingForStackLookup",
            "Effect": "Allow",
            "Action": "tag:GetResources",
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "aws:RequestedRegion": "{{REGION}}"
                }
            }
        },
        {
            "Sid": "STSCallerIdentity",
            "Effect": "Allow",
            "Action": "sts:GetCallerIdentity",
            "Resource": "*"
        }
    ]
}
```

Oltre alla politica di esempio precedente, che fornisce le autorizzazioni `AWSSupport-TroubleshootEKSNetwork` solo per, sono necessarie politiche aggiuntive per le esecuzioni del runbook secondario di e. `AWSSupport-SetupK8sApiProxyForEKS` `AWSSupport-CollectEKSLinuxNodeStatistics` Le seguenti politiche di esempio si applicano a questi documenti:

Autorizzazioni richieste per`AWSSupport-SetupK8sApiProxyForEKS`:

```
{
    "Version":"2012-10-17",                   
    "Statement": [
        {
            "Action": [
                "tag:GetResources",
                "tag:TagResources",
                "ec2:CreateNetworkInterface",
                "ec2:DescribeNetworkInterfaces",
                "ec2:DescribeRouteTables",
                "ec2:DescribeSecurityGroups",
                "ec2:DescribeSubnets",
                "ec2:DescribeVpcs",
                "ec2:DeleteNetworkInterface",
                "eks:DescribeCluster",
                "iam:GetRole",
                "cloudformation:DescribeStacks",
                "logs:DescribeLogGroups",
                "logs:DescribeLogStreams",
                "lambda:GetFunction",
                "lambda:ListTags",
                "logs:ListTagsForResource"
            ],
            "Resource": "*",
            "Effect": "Allow",
            "Sid": "AllowActionsWithoutConditions"
        },
        {
            "Condition": {
                "StringEquals": {
                    "aws:RequestTag/AWSSupport-SetupK8sApiProxyForEKS": "true"
                }
            },
            "Action": "iam:CreateRole",
            "Resource": [
                "arn:aws:iam::{{ACCOUNTID}}:role/Automation-K8sProxy*"
            ],
            "Effect": "Allow",
            "Sid": "AllowCreateRoleWithRequiredTag"
        },
        {
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/AWSSupport-SetupK8sApiProxyForEKS": "true"
                }
            },
            "Action": [
                "iam:DeleteRole",
                "iam:TagRole",
                "iam:UntagRole"
            ],
            "Resource": [
                "arn:aws:iam::{{ACCOUNTID}}:role/Automation-K8sProxy*"
            ],
            "Effect": "Allow",
            "Sid": "IAMActions"
        },
        {
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/AWSSupport-SetupK8sApiProxyForEKS": "true"
                },
                "StringLike": {
                    "iam:PolicyARN": [
                        "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
                        "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
                    ]
                }
            },
            "Action": [
                "iam:AttachRolePolicy",
                "iam:DetachRolePolicy"
            ],
            "Resource": [
                "arn:aws:iam::{{ACCOUNTID}}:role/Automation-K8sProxy*"
            ],
            "Effect": "Allow",
            "Sid": "AttachRolePolicy"
        },
        {
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/AWSSupport-SetupK8sApiProxyForEKS": "true"
                }
            },
            "Action": [
                "lambda:CreateFunction",
                "lambda:DeleteFunction",
                "lambda:TagResource",
                "lambda:UntagResource",
                "lambda:UpdateFunctionCode"
            ],
            "Resource": "arn:aws:lambda:{{REGION}}:{{ACCOUNTID}}:function:Automation-K8sProxy*",
            "Effect": "Allow",
            "Sid": "LambdaActions"
        },
        {
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/AWSSupport-SetupK8sApiProxyForEKS": "true"
                }
            },
            "Action": [
                "cloudformation:CreateStack",
                "cloudformation:DeleteStack",
                "cloudformation:UpdateStack"
            ],
            "Resource": "arn:aws:cloudformation:{{REGION}}:{{ACCOUNTID}}:stack/AWSSupport-SetupK8sApiProxyForEKS*",
            "Effect": "Allow",
            "Sid": "CloudFormationActions"
        },
        {
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/AWSSupport-SetupK8sApiProxyForEKS": "true"
                }
            },
            "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents",
                "logs:PutRetentionPolicy",
                "logs:TagResource",
                "logs:UntagResource"
            ],
            "Resource": [
                "arn:aws:logs:{{REGION}}:{{ACCOUNTID}}:log-group:/aws/lambda/Automation-K8sProxy*",
                "arn:aws:logs:{{REGION}}:{{ACCOUNTID}}:log-group:/aws/lambda/Automation-K8sProxy*:*"
            ],
            "Effect": "Allow",
            "Sid": "LogsActions"
        },
        {
            "Condition": {
                "StringLikeIfExists": {
                    "iam:PassedToService": "lambda.amazonaws.com"
                }
            },
            "Action": [
                "iam:PassRole"
            ],
            "Resource": [
                "arn:aws:iam::{{ACCOUNTID}}:role/Automation-K8sProxy-Role*"
            ],
            "Effect": "Allow",
            "Sid": "PassRoleToLambda"
        }
    ]
}
```

Autorizzazioni richieste per: `AWSSupport-CollectEKSLinuxNodeStatistics`

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetAccountPublicAccessBlock"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetBucketPublicAccessBlock",
                "s3:GetBucketAcl",
                "s3:GetBucketPolicyStatus",
                "s3:GetBucketLocation",
                "s3:GetEncryptionConfiguration"
            ],
            "Resource": "arn:aws:s3:::{{S3_BUCKET_NAME}}"
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject"
            ],
            "Resource": "arn:aws:s3:::{{S3_BUCKET_NAME}}/*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "ssm:DescribeInstanceInformation"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "ssm:SendCommand"
            ],
            "Resource": [
                "arn:aws:ssm:*:*:document/AWS-RunShellScript",
                "arn:aws:ec2:*:{{ACCOUNTID}}:instance/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "ssm:GetCommandInvocation"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeInstances"
            ],
            "Resource": "*"
        }
    ]
}
```

## Istruzioni
<a name="automation-awssupport-troubleshooteksnetwork-instructions"></a>

1. Apri [`AWSSupport-TroubleshootEKSNetwork`](https://console.aws.amazon.com/systems-manager/documents/AWSSupport-TroubleshootEKSNetwork/description) in Systems Manager sotto Documenti.

1. Scegli **Esegui automazione**.

1. Per i parametri di input, inserisci quanto segue:
   + **AutomationAssumeRole (Facoltativo): **

     L'ARN del ruolo IAM che consente a Systems Manager Automation di eseguire le azioni per tuo conto. Se non viene specificato alcun ruolo, Systems Manager Automation utilizza le autorizzazioni dell'utente per eseguire questo runbook.
   + **S3BucketName (Obbligatorio): **

     Nome del bucket Amazon S3 per il caricamento delle risorse per la risoluzione dei problemi.
   + **SourceClusterName (Obbligatorio): **

     Nome del cluster Amazon EKS di origine da risolvere.
   + **SourcePodName (Obbligatorio): **

     Nome del Kubernetes pod sorgente che avvia la connessione di rete.
   + **SourcePodNamespace (Obbligatorio): **

     Namespace in cui risiede il Kubernetes pod sorgente.
   + **DestinationType (Obbligatorio): **

     Tipo di destinazione della connessione di rete. Valori validi: `POD`, `SERVICE`, `IP` o `DNS`.
   + **ConnectionProtocol (Obbligatorio): **

     Protocollo per la connessione di rete. Valori validi: `tcp`, `udp` o `sctp`.
   + **DestinationPort (Obbligatorio): **

     La porta di destinazione della connessione di rete.
   + **DestinationClusterName (Facoltativo): **

     Il nome del cluster Amazon EKS di destinazione (obbligatorio per i tipi di destinazione POD e SERVICE).
   + **DestinationPodName (Facoltativo): **

     Il nome del Kubernetes pod di destinazione (obbligatorio per il tipo di destinazione POD).
   + **DestinationPodNamespace (Facoltativo): **

     Namespace in cui risiede il Kubernetes pod di destinazione (obbligatorio per il tipo di destinazione POD).
   + **DestinationServiceName (Facoltativo): **

     Il nome del Kubernetes servizio di destinazione (obbligatorio per il tipo di destinazione del SERVIZIO).
   + **DestinationServiceNamespace (Facoltativo): **

     Namespace in cui risiede il Kubernetes servizio di destinazione (obbligatorio per il tipo di destinazione SERVICE).
   + **DestinationIpAddress (Facoltativo): **

     Indirizzo IPv4 o IPv6 di destinazione (richiesto per il tipo di destinazione IP).
   + **DestinationDnsName (Opzionale): **

     Nome DNS di destinazione (obbligatorio per il tipo di destinazione DNS).

1. Scegli **Esegui**.

1. L'automazione viene avviata. Monitora lo stato dell'esecuzione nella ** scheda ** Esecuzioni.

1. Il documento esegue automaticamente le seguenti operazioni:
   + **`ValidateTroubleshootingParameters`**:

     Verifica i parametri di input necessari per la risoluzione dei problemi, ad esempio se il cluster esiste.
   + **`SetupAuthProxyForSourceEKSCluster`**:

     Esegue il `AWSSupport-SetupK8sApiProxyForEKS` documento per configurare una funzione Lambda per effettuare chiamate API Amazon EKS sul cluster Amazon EKS di origine.
   + **`BranchOnDestinationProxySetupRequired`**:

     Determina se eseguire `SetupK8sApiProxyForEKS` l'esecuzione per un cluster di destinazione in base al tipo di destinazione.
   + **`SetupAuthProxyForDestinationEKSCluster`**:

     Se necessario, esegue il `AWSSupport-SetupK8sApiProxyForEKS` documento per configurare una funzione Lambda per il cluster Amazon EKS di destinazione.
   + **`CollectSourcePodData`**:

     Raccoglie e convalida le informazioni del pod sorgente.
   + **`BranchOnSourcePodComputeEngine`**:

     Indica se il Kubernetes pod di origine viene eseguito su Amazon EC2 per raccogliere statistiche Linux per il nodo.
   + **`CollectSourceLinuxNodeStatistics`**:

     Se il pod di origine viene eseguito su Amazon EC2, esegue il `AWSSupport-CollectEKSLinuxNodeStatistics` documento per recuperare le statistiche Linux dal nodo del Kubernetes pod di origine.
   + **`CollectDestinationData`**:

     Raccoglie e convalida le informazioni sulla destinazione.
   + **`BranchOnDestinationResults`**:

     Indica se il Kubernetes pod di destinazione viene eseguito su Amazon EC2 per raccogliere statistiche Linux per il nodo.
   + **`CollectDestinationLinuxNodeStatistics`**:

     Se il pod di destinazione viene eseguito su Amazon EC2, esegue il `AWSSupport-CollectEKSLinuxNodeStatistics` documento per recuperare le statistiche Linux dal nodo Amazon EKS di destinazione.
   + **`CleanupAuthProxyForSourceEKSCluster`**:

     Esegue il `AWSSupport-SetupK8sApiProxyForEKS` documento utilizzando l'operazione Cleanup per ripulire le risorse create per il cluster di origine.
   + **`CleanupAuthProxyForDestinationEKSCluster`**:

     Se applicabile, esegue il `AWSSupport-SetupK8sApiProxyForEKS` documento utilizzando l'operazione Cleanup per ripulire le risorse create per il cluster di destinazione.
   + **`GenerateReport`**:

     Genera un rapporto per il flusso di risoluzione dei problemi.

1. Al termine dell'automazione, esamina la sezione Output per i risultati dell'esecuzione.

## Riferimenti
<a name="automation-awssupport-troubleshooteksnetwork-references"></a>

Systems Manager Automation
+ Per ulteriori informazioni, consulta [ Eseguire un'automazione. ](https://docs.aws.amazon.com//systems-manager/latest/userguide/automation-working-executing.html)
+ Per ulteriori informazioni, consulta [ Configurare l'automazione](https://docs.aws.amazon.com//systems-manager/latest/userguide/automation-setup.html).
+ Per ulteriori informazioni, consulta [ Support Automation Workflows](https://aws.amazon.com/premiumsupport/technology/saw/).