############################################################# ## NOT FOR PRODUCTION USE. ## ## THE CONTENT OF THIS FILE IS FOR LEARNING PURPOSES ONLY ## ## created by David Surey, Amazon Web Services, 2020 ## ############################################################# - name: create amazon-cloudwatch namespace delegate_to: "{{ EKSBastionInstancePublicIP }}" kubernetes.core.k8s: state: present definition: apiVersion: v1 kind: Namespace metadata: name: amazon-cloudwatch - name: get notegroups rolename delegate_to: "{{ EKSBastionInstancePublicIP }}" shell: > aws cloudformation describe-stack-resources --region {{ eksexample_region }} --stack-name eksctl-{{ eksexample_clustername }}-nodegroup-{{ eksexample_clustername }}-linux-nodes \ | jq -r '.StackResources[] | select(.ResourceType=="AWS::IAM::Role") | .PhysicalResourceId' register: eks_nodegroup_role_name - name: create Roles and Policies for container insights cloudformation: profile: "{{ eksexample_aws_profilename }}" stack_name: "{{ eksexample_clustername }}-container-insights-policy" state: present region: "{{ eksexample_region }}" template: "./cloudformation/eks-container-insights-iam.template.yaml" template_parameters: nodegroupRoleName: "{{ eks_nodegroup_role_name.stdout }}" - name: Download cloudwatch insights manifests to the cluster. delegate_to: "{{ EKSBastionInstancePublicIP }}" ansible.builtin.get_url: url: https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/quickstart/cwagent-fluent-bit-quickstart.yaml dest: ~/cwagent-fluent-bit-quickstart.yaml mode: '0664' - name: Replace variables with values delegate_to: "{{ EKSBastionInstancePublicIP }}" ansible.builtin.replace: path: ~/cwagent-fluent-bit-quickstart.yaml regexp: "{{ item.key }}" replace: "{{ item.value }}" loop: "{{ replace_data | dict2items }}" vars: replace_data: '\{\{cluster_name\}\}': "'{{ eksexample_clustername }}'" '\{\{region_name\}\}': "'{{ eksexample_region }}'" '\{\{http_server_toggle\}\}': "'On'" '\{\{read_from_tail\}\}': "'On'" '\{\{read_from_head\}\}': "'Off'" '\{\{http_server_port\}\}': "'2020'" - name: Apply the container insights manifest to the cluster. delegate_to: "{{ EKSBastionInstancePublicIP }}" kubernetes.core.k8s: state: present src: ~/cwagent-fluent-bit-quickstart.yaml