Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Amazon Managed service for Prometheus controller support #28

Merged
merged 1 commit into from
Nov 21, 2022

Conversation

pdemagny
Copy link
Contributor

@pdemagny pdemagny commented Nov 20, 2022

What does this PR do?

Hello !
This PR adds support for the Amazon Managed service for Prometheus GA controller for ACK. Thus allowing the creation of AMP resources (AlertManagerDefinition, RuleGroupsNamespace, Workspace) with ACK.

Motivation

I needed to test the AMP integration with KubeCost on EKS, all of this with the terraform-aws-eks-blueprints.
I saw this great and helpful repository existed but lacked support for AMP, so I thought about contributing it ;)

Test Results

I created an EKS cluster with the terraform-aws-eks-blueprints and with the ACK AMP controller installed with my fork:

module "eks_blueprints_ack_addons" {
  source = "github.com/pdemagny/terraform-aws-eks-ack-addons?ref=feat-amp-support"

  cluster_id = module.eks_blueprints.eks_cluster_id
  # Wait for data plane to be ready
  data_plane_wait_arn = module.eks_blueprints.managed_node_group_arn[0]

  enable_api_gatewayv2 = false
  enable_dynamodb      = false
  enable_s3            = false
  enable_rds           = false
  enable_amp           = true

  tags = local.tags
}

Which produces a working installation of the controller:

❯ k get pods -n ack-amp
NAME                       READY   STATUS    RESTARTS   AGE
ack-amp-5fdc849b48-j4nsc   1/1     Running   0          91m

I also created an AMP Workspace in my AWS account:

apiVersion: prometheusservice.services.k8s.aws/v1alpha1
kind: Workspace
metadata:
  name: "ack-amp-test-workspace"
spec:
  alias: "ack-amp-test-workspace"
❯ k logs -n ack-amp ack-amp-5fdc849b48-j4nsc
...
2022-11-20T16:57:36.835Z	INFO	ackrt	created new resource	{"account": "<REDACTED>", "role": "", "region": "eu-west-1", "kind": "Workspace", "namespace": "default", "name": "ack-amp-test-workspace", "is_adopted": false, "generation": 1}
2022-11-20T17:00:07.533Z	INFO	ackrt	deleted resource	{"account": "<REDACTED>", "role": "", "region": "eu-west-1", "kind": "Workspace", "namespace": "default", "name": "ack-amp-test-workspace", "generation": 2}
❯ k describe workspaces.prometheusservice.services.k8s.aws -n default
Name:         ack-amp-test-workspace
Namespace:    default
Labels:       <none>
Annotations:  <none>
API Version:  prometheusservice.services.k8s.aws/v1alpha1
Kind:         Workspace
Metadata:
  Creation Timestamp:  2022-11-20T16:57:36Z
  Finalizers:
    finalizers.prometheusservice.services.k8s.aws/Workspace
  Generation:  1
  Managed Fields:
    API Version:  prometheusservice.services.k8s.aws/v1alpha1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:finalizers:
          .:
          v:"finalizers.prometheusservice.services.k8s.aws/Workspace":
    Manager:      controller
    Operation:    Update
    Time:         2022-11-20T16:57:36Z
    API Version:  prometheusservice.services.k8s.aws/v1alpha1
    Fields Type:  FieldsV1
    fieldsV1:
      f:status:
        .:
        f:ackResourceMetadata:
          .:
          f:arn:
          f:ownerAccountID:
          f:region:
        f:conditions:
        f:status:
          .:
          f:statusCode:
        f:workspaceID:
    Manager:      controller
    Operation:    Update
    Subresource:  status
    Time:         2022-11-20T16:57:36Z
    API Version:  prometheusservice.services.k8s.aws/v1alpha1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .:
          f:kubectl.kubernetes.io/last-applied-configuration:
      f:spec:
        .:
        f:alias:
    Manager:         kubectl-client-side-apply
    Operation:       Update
    Time:            2022-11-20T16:57:36Z
  Resource Version:  31692
  UID:               0a3ac219-fc52-4268-83ae-1bd52a04cecd
Spec:
  Alias:  ack-amp-test-workspace
Status:
  Ack Resource Metadata:
    Arn:               arn:aws:aps:eu-west-1:<REDACTED>:workspace/ws-<REDACTED>
    Owner Account ID:  <REDACTED>
    Region:            eu-west-1
  Conditions:
    Last Transition Time:  2022-11-20T16:58:06Z
    Message:               Resource synced successfully
    Reason:                
    Status:                True
    Type:                  ACK.ResourceSynced
  Status:
    Status Code:  ACTIVE
  Workspace ID:   ws-<REDACTED>
Events:           <none>

Additional Notes

❯ pre-commit run -a
Terraform fmt............................................................Passed
Terraform docs...........................................................Passed
Terraform validate with tflint...........................................Passed
Terraform validate.......................................................Passed
check for merge conflicts................................................Passed
fix end of files.........................................................Passed

@pdemagny pdemagny requested a review from a team as a code owner November 20, 2022 17:10
Copy link
Contributor

@askulkarni2 askulkarni2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pdemagny thanks for the contribution!

@askulkarni2 askulkarni2 merged commit 950645c into aws-ia:main Nov 21, 2022
@pdemagny pdemagny deleted the feat-amp-support branch November 21, 2022 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ACK Amazon Managed service for Prometheus controller
2 participants