AWS announces preview of AWS Interconnect - multicloud
AWS announces AWS Interconnect – multicloud (preview), providing simple, resilient, high-speed private connections to other cloud service providers. AWS Interconnect - multicloud is easy to configure and provides high-speed, resilient connectivity with dedicated bandwidth, enabling customers to interconnect AWS networking services such as AWS Transit Gateway, AWS Cloud WAN, and Amazon VPC to other cloud service providers with ease.
Come posso automatizzare la configurazione del proxy HTTP per i nodi worker EKS con i dati degli utenti?
Desidero automatizzare la configurazione del proxy HTTP per i nodi di lavoro di Amazon Elastic Kubernetes Service (Amazon EKS) con i dati degli utenti.
Breve descrizione
Per configurare un proxy sui nodi worker, devi configurare i componenti necessari del tuo cluster Amazon EKS per comunicare dal proxy. I componenti includono, ma non sono limitati a, il servizio kubelet systemd, kube-proxy, aws-node pods e yum update. Per automatizzare la configurazione del proxy per i nodi worker con Docker runtime, procedi come segue:
Nota: la seguente risoluzione si applica solo ai nodi in cui il runtime sottostante è Docker e non si applica ai nodi con runtime containerd. Per i nodi con runtime containerd, consulta Come posso automatizzare la configurazione del proxy HTTP per i nodi containerd EKS?
Risoluzione
- Trova il blocco IP CIDR del tuo cluster:
$ kubectl get service kubernetes -o jsonpath='{.spec.clusterIP}'; echo
Il comando precedente restituisce 10.100.0.1 o 172.20.0.1. Ciò significa che il blocco CIDR IP del cluster è 10.100.0.0/16 o 172.20.0.0/16.
- Crea un file ConfigMap denominato proxy-env-vars-config.yaml in base all'output del comando nel passaggio 1.
Se l'output ha un IP compreso nell'intervallo 172.20.x.x, struttura il file ConfigMap come segue:
apiVersion: v1 kind: ConfigMap metadata: name: proxy-environment-variables namespace: kube-system data: HTTP_PROXY: http://customer.proxy.host:proxy_port HTTPS_PROXY: http://customer.proxy.host:proxy_port NO_PROXY: 172.20.0.0/16,localhost,127.0.0.1,VPC_CIDR_RANGE,169.254.169.254,.internal,s3.amazonaws.com,.s3.us-east-1.amazonaws.com,api.ecr.us-east-1.amazonaws.com,dkr.ecr.us-east-1.amazonaws.com,ec2.us-east-1.amazonaws.com
Nota: sostituisci VPC_CIDR_RANGE con il blocco CIDR IPv4 del VPC del tuo cluster.
Se l'output ha un IP compreso nell'intervallo 10.100.x.x, struttura il file ConfigMap come segue:
apiVersion: v1 kind: ConfigMap metadata: name: proxy-environment-variables namespace: kube-system data: HTTP_PROXY: http://customer.proxy.host:proxy_port HTTPS_PROXY: http://customer.proxy.host:proxy_port NO_PROXY: 10.100.0.0/16,localhost,127.0.0.1,VPC_CIDR_RANGE,169.254.169.254,.internal,s3.amazonaws.com,.s3.us-east-1.amazonaws.com,api.ecr.us-east-1.amazonaws.com,dkr.ecr.us-east-1.amazonaws.com,ec2.us-east-1.amazonaws.com
Nota: sostituisci VPC_CIDR_RANGE con il blocco CIDR IPv4 del VPC del tuo cluster.
I cluster Amazon EKS con accesso privato agli endpoint del server API, sottoreti private e senza accesso a Internet richiedono endpoint aggiuntivi. Se stai creando un cluster con la configurazione precedente, devi creare e aggiungere endpoint per i seguenti servizi:
- Amazon Elastic Container Registry (Amazon ECR)
- Amazon Simple Storage Service (Amazon S3)
- Amazon Elastic Compute Cloud (Amazon EC2)
- Amazon Virtual Private Cloud (Amazon VPC)
Ad esempio, puoi utilizzare i seguenti endpoint: api.ecr.us-east-1.amazonaws.com, dkr. ecr.us-east-1.amazonaws.com, s3.amazonaws.com, s3.us-east-1.amazonaws.com e ec2.us-east-1.amazonaws.com.
Importante: è necessario aggiungere il sottodominio pubblico dell'endpoint alla variabile NO_PROXY. Ad esempio, aggiungi il dominio**.s3.us-east-1.amazonaws.com** per Amazon S3 nella Regione AWS us-east-1. Se attivi l'accesso privato degli endpoint per il tuo cluster Amazon EKS, devi aggiungere l'endpoint Amazon EKS alla variabile NO_PROXY. Ad esempio, aggiungi il dominio .us-east-1.eks.amazonaws.com per il tuo cluster Amazon EKS nella Regione AWS us-east-1.
-
Verifica che la variabile NO_PROXY in configmap/proxy-environment-variables (utilizzata dai pod kube-proxy e aws-node) includa lo spazio degli indirizzi IP del cluster Kubernetes. Ad esempio, 10.100.0.0/16 viene utilizzato nell'esempio di codice precedente per il file ConfigMap in cui l'intervallo IP è compreso tra 10.100.x.x.
-
Applica la ConfigMap:
$ kubectl apply -f /path/to/yaml/proxy-env-vars-config.yaml
- Per configurare il daemon Docker e kubelet, inserisci i dati utente nei tuoi nodi worker. Ad esempio:
Content-Type: multipart/mixed; boundary="==BOUNDARY==" MIME-Version: 1.0 --==BOUNDARY== Content-Type: text/cloud-boothook; charset="us-ascii" #Set the proxy hostname and port PROXY="proxy.local:3128" MAC=$(curl -s http://169.254.169.254/latest/meta-data/mac/) VPC_CIDR=$(curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MAC/vpc-ipv4-cidr-blocks | xargs | tr ' ' ',') #Create the docker systemd directory mkdir -p /etc/systemd/system/docker.service.d #Configure yum to use the proxy cloud-init-per instance yum_proxy_config cat << EOF >> /etc/yum.conf proxy=http://$PROXY EOF #Set the proxy for future processes, and use as an include file cloud-init-per instance proxy_config cat << EOF >> /etc/environment http_proxy=http://$PROXY https_proxy=http://$PROXY HTTP_PROXY=http://$PROXY HTTPS_PROXY=http://$PROXY no_proxy=$VPC_CIDR,localhost,127.0.0.1,169.254.169.254,.internal,s3.amazonaws.com,.s3.us-east-1.amazonaws.com,api.ecr.us-east-1.amazonaws.com,dkr.ecr.us-east-1.amazonaws.com,ec2.us-east-1.amazonaws.com NO_PROXY=$VPC_CIDR,localhost,127.0.0.1,169.254.169.254,.internal,s3.amazonaws.com,.s3.us-east-1.amazonaws.com,api.ecr.us-east-1.amazonaws.com,dkr.ecr.us-east-1.amazonaws.com,ec2.us-east-1.amazonaws.com EOF #Configure docker with the proxy cloud-init-per instance docker_proxy_config tee <<EOF /etc/systemd/system/docker.service.d/proxy.conf >/dev/null [Service] EnvironmentFile=/etc/environment EOF #Configure the kubelet with the proxy cloud-init-per instance kubelet_proxy_config tee <<EOF /etc/systemd/system/kubelet.service.d/proxy.conf >/dev/null [Service] EnvironmentFile=/etc/environment EOF #Reload the daemon and restart docker to reflect proxy configuration at launch of instance cloud-init-per instance reload_daemon systemctl daemon-reload cloud-init-per instance enable_docker systemctl enable --now --no-block docker --==BOUNDARY== Content-Type:text/x-shellscript; charset="us-ascii" #!/bin/bash set -o xtrace #Set the proxy variables before running the bootstrap.sh script set -a source /etc/environment /etc/eks/bootstrap.sh ${ClusterName} ${BootstrapArguments} # Use the cfn-signal only if the node is created through an AWS CloudFormation stack and needs to signal back to an AWS CloudFormation resource (CFN_RESOURCE_LOGICAL_NAME) that waits for a signal from this EC2 instance to progress through either: # - CreationPolicy https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-creationpolicy.html # - UpdatePolicy https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html # cfn-signal will signal back to AWS CloudFormation using https transport, so set the proxy for an HTTPS connection to AWS CloudFormation /opt/aws/bin/cfn-signal --exit-code $? \ --stack ${AWS::StackName} \ --resource CFN_RESOURCE_LOGICAL_NAME \ --region ${AWS::Region} \ --https-proxy $HTTPS_PROXY --==BOUNDARY==--
Importante: è necessario aggiornare o creare i file di configurazione yum, Docker e kubelet prima di avviare il demone Docker e kubelet.
Per un esempio di dati utente che vengono inseriti nei nodi worker utilizzando un modello AWS CloudFormation, consulta Launching self-managed Amazon Linux nodes.
- Aggiorna i pod aws-node e kube-proxy:
$ kubectl patch -n kube-system -p '{ "spec": {"template": { "spec": { "containers": [ { "name": "aws-node", "envFrom": [ { "configMapRef": {"name": "proxy-environment-variables"} } ] } ] } } } }' daemonset aws-node $ kubectl patch -n kube-system -p '{ "spec": {"template":{ "spec": { "containers": [ { "name": "kube-proxy", "envFrom": [ { "configMapRef": {"name": "proxy-environment-variables"} } ] } ] } } } }' daemonset kube-proxy
Se modifichi la ConfigMap, applica gli aggiornamenti e imposta nuovamente ConfigMap nei pod. Ad esempio:
$ kubectl set env daemonset/kube-proxy --namespace=kube-system --from=configmap/proxy-environment-variables --containers='*' $ kubectl set env daemonset/aws-node --namespace=kube-system --from=configmap/proxy-environment-variables --containers='*'
Importante: è necessario aggiornare tutte le modifiche YAML agli oggetti Kubernetes kube-proxy o aws-node quando questi oggetti vengono aggiornati. Per aggiornare una ConfigMap a un valore predefinito, usa i comandi eksctl utils update-kube-proxy o eksctl utils update-aws-node.
Suggerimento: se il proxy perde la connettività con il server API, diventa un singolo punto di errore e il comportamento del cluster può essere imprevedibile. Per evitare che il proxy diventi un unico punto di errore, esegui il proxy dietro un namespace di rilevamento servizi o un sistema di bilanciamento del carico.
- Conferma che le variabili proxy siano utilizzate nei pod kube-proxy e aws-node:
$ kubectl describe pod kube-proxy-xxxx -n kube-system
L'output dovrebbe essere simile al seguente:
Environment: HTTPS_PROXY: <set to the key 'HTTPS_PROXY' of config map 'proxy-environment-variables'> Optional: false HTTP_PROXY: <set to the key 'HTTP_PROXY' of config map 'proxy-environment-variables'> Optional: false NO_PROXY: <set to the key 'NO_PROXY' of config map 'proxy-environment-variables'> Optional: false
Se non utilizzi AWS PrivateLink, verifica l'accesso agli endpoint API tramite un server proxy per Amazon EC2, Amazon ECR e Amazon S3.
- Argomenti
- Containers
- Lingua
- Italiano
Video correlati

