Overview


 

Crossplane 이란 “클라우드 네이티브 제어 영역 프레임워크” 이며,

코드를 작성할 필요 없이 어플리케이션과 인프라를 오케스트레이션 할 수 있는 프레임워크입니다.

쉽게 말해서 Kubernetes 클러스터에서 인프라 자원을 관리하기 위한 오픈 소스 툴입니다.

 

클라우드 업체에서 컨트롤 플레인을 사용해 플랫폼을 구축하듯이,

조직이 플랫폼을 구축할 수 있게 하는 kubernetes 기반 오픈 소스 CNCF 프로젝트입니다.

 

오케스트레이션을 위한 확장성있는 백엔드와 선언적인 API를 정의할 수 있는 프런트엔드를 갖추고 있습니다.

Kubernetes 기반으로 구축되어 RBAC 등 컨테이너 뿐 아니라 모든 것을 조율할 수 있으며 클라우드 기본 도구와 통합 가능 합니다.

 

Upbound 라는 마켓플레이스를 통해 Crossplane Provider 과 구성을 쉽게 찾을 수 있습니다.

또한 Apache 2.0 라이센스를 따라 출시된 오픈 소스이며 커뮤니티 중심 프레임워크 입니다.

 


 

 

 

How to use


 

Helm 이 설치되어있다면, 헬름을 통해 Crossplane을 설치할 수 있습니다.

 

helm repo add crossplane-stable https://charts.crossplane.io/stable
helm repo update
helm install crossplane --namespace crossplane-system crossplane-stable/crossplane

 

 

또는 Crossplan Github Repository 에서 직접 yaml 파일로 다운받아 설치할 수 있습니다.

 

kubectl apply -f https://raw.githubusercontent.com/crossplane/crossplane/main/deploy/release/crossplane/provider-latest.yaml

 

 

본인은 AWS에 익숙하므로, 사용을 위해 AWS Provider 기반으로 기술하겠습니다.

 

IAM credential 이 필요하므로, 해당 경우에는 IAM Role을 사용하는 기반으로 기술합니다.

 

먼저 사용할 IAM Role 의 Trust Relationship 을 정합니다.

 

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::123456789012:root" // 또는 Crossplane을 실행하는 IAM User의 ARN
      },
      "Action": "sts:AssumeRole"
    },
    {
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::<AWS_ACCOUNT_ID>:oidc-provider/<OIDC_PROVIDER_URL>" // Kubernetes OIDC Provider의 ARN
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": {
          "oidc.eks.amazonaws.com/id/<CLUSTER_OIDC_ISSUER>": "system:serviceaccount:<KUBE_NAMESPACE>:<SERVICE_ACCOUNT_NAME>"
        }
      }
    }
  ]
}

 

 

AWS IAM Authenticator 를 설치합니다.

 

kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-iam-authenticator/master/dist/aws-iam-authenticator.yaml

 

 

Crossplane 이 사용할 Service Account 를 쿠버네티스에 생성하고 역할 바인딩을 합니다.

 

apiVersion: v1
kind: ServiceAccount
metadata:
  name: crossplane-serviceaccount
  namespace: crossplane-system

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: crossplane-rolebinding
  namespace: crossplane-system
subjects:
- kind: ServiceAccount
  name: crossplane-serviceaccount
  namespace: crossplane-system
roleRef:
  kind: ClusterRole
  name: system:node-proxier // 또는 사용 권한이 필요한 ClusterRole
  apiGroup: rbac.authorization.k8s.io

 

 

이제 Crossplane 이 IAM 역할을 사용할 수 있도록 AWS ProviderConfig 를 설정합니다.

 

apiVersion: aws.crossplane.io/v1alpha3
kind: ProviderConfig
metadata:
  name: aws-providerconfig
spec:
  credentials:
    source: ProviderSecret
    providerSecretRef:
      namespace: crossplane-system
      name: aws-provider-secret

 

 

사용 예)

Crossplane을 사용하여 AWS RDS 인스턴스를 생성할 때, Crossplane은 해당 IAM Role을 통해 AWS 자원에 접근하게 됩니다. 

 

apiVersion: database.aws.crossplane.io/v1alpha1
kind: RDSInstance
metadata:
  name: example-db
spec:
  engine: mysql
  engineVersion: "5.7"
  instanceClass: db.t2.micro
  storageGB: 20
  multiAZ: false
  ... (기타 필요한 설정)

 

 

사용 명령어 예시

 

# get crossplane resources
kubectl get <crossplane-resource-type>
kubectl get rdsinstances.aws.crossplane.io
kubectl get rdsinstances.aws.crossplane.io -l app=example-app
kubectl get rdsinstances.aws.crossplane.io --field-selector=status.phase=Failed

# describe
kubectl describe <crossplane-resource-type> <resource-name>
kubectl describe rdsinstances.aws.crossplane.io example-db

# create resources
kubectl apply -f <yaml-file>

# delete resources
kubectl delete <crossplane-resource-type> <resource-name>
kubectl delete rdsinstances.aws.crossplane.io example-db

 

 

Official document to start Crossplane: https://docs.crossplane.io/latest/software/install/

'devops > ETC' 카테고리의 다른 글

Hashcorp Vault with a simple demo  (0) 2024.06.23
Pulumi with a simple demo  (0) 2024.06.23
Istio - service mesh  (2) 2024.06.15
Aqua Security / Trivy  (2) 2024.06.15
Automation technologies including tech companies  (0) 2023.08.04

 

argocd를 helm 을 이용해 설치하고 다음 값을 설정해서 설치하였다.

 

USER-SUPPLIED VALUES:
rbacConfig:
  groups:
  - name: admin
    rules:
    - apiGroups:
      - '*'
      resources:
      - '*'
      verbs:
      - '*'
  users:
  - groups:
    - admin
    name: admin
server:
  extraArgs:
  - --insecure
  ingress:
    annotations:
      kubernetes.io/ingress.class: nginx
      nginx.ingres.kubernetes.io/affinity: cookie
      nginx.ingress.kubernetes.io/session-cookie-expires: "172800"
      nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"
      nginx.ingress.kubernetes.io/session-cookie-name: route
      cert-manager.io/cluster-issuer: letsencrypt-prod
      acme.cert-manager.io/http01-edit-in-place: "true"
      meta.helm.sh/release-name: argocd
      meta.helm.sh/release-namespace: argocd
      
    enabled: true
    hosts:
    - argocd.yourdomain.com
    ingressClassName: nginx
  service:
    type: NodePort
        # -- Ingress TLS configuration
    tls: []
        # - secretName: argocd-applicationset-tls
        #   hosts:
        #     - argocd-applicationset.example.com

 

인증서를 쓰는 도메인을 사용할 경우 tls에 기술한다.

helm 설치 후 해당 네임스페이스에 기술한 시크릿이 생성되었는지 확인한다.

tls 설정 부분을 위한 annotation이 부족한 경우 정상적으로 시크릿이 생성되지 않고 사이트에 불완전한 커넥션 표시가 뜰 수 있다.

위 동작을 위해 cert-manager가 쿠버네티스 클러스터에 미리 설치되어 있어야 한다.

 

또한 인그레스를 활성화하는 값을 사용했으므로 해당 네임스페이스에 정의한 ingress가 생성되었는지 확인한다.

 

 

어플리케이션 배포에 앞서 test Project를 생성하고 테스트를 위해 권한이 있는 role을 부여했다.

Clusters엔 현재 argocd 를 올려놓은 Cluster 가 등록되어있는 상태다.

 

이후 Applications 에서 EDIT AS YAML을 선택하여 아래와 같이 기본적인 테스트를 위한 설정을 입력했다.

 

project: test
source:
  repoURL: 'https://github.com/argoproj/argocd-example-apps'
  path: guestbook
  targetRevision: HEAD
destination:
  server: 'https://kubernetes.default.svc'
  namespace: default

 

어플리케이션이 처음 등록에 성공하면 Out of sync 상태로 표시되어있고,

해당 어플리케이션을 sync 해주면 세부사항이 바뀌면서 실제로 해당 네임스페이스에 리소스가 배포된 것을 확인할 수 있다.

 

 

등록했던 어플리케이션을 Delete 선택하여 삭제하면 다음과 같이 배포되었던 리소스도 삭제되었다.

 

 

Error message:

│ Error: Failed to construct REST client
│
│   with module.kubernetes.kubernetes_manifest.eniconfig["xx-northeast-xx"],
│   on modules/kubernetes/xx_network.tf line 41, in resource "kubernetes_manifest" "eniconfig":
│   41: resource "kubernetes_manifest" "eniconfig" {
│
│ cannot create REST client: no client config

From the official document of Hashcorp:

This resource requires API access during planning time. This means the cluster has to be accessible at plan time and thus cannot be created in the same apply operation. We recommend only using this resource for custom resources or resources not yet fully supported by the provider.

 

tfvars를 -var-file= 로 지정하여 terraform plan 시, 특정 모듈의 kubernetes_manifest 리소스 부분과 관련해서 no client config 에러가 발생하였다.

해시코프 공식 문서에 따르면 지정한 리소스가 테라폼 플래닝 중에 api 접근이 필요하며, 즉 terraform plan이 실행될 때 해당 클러스터(eks cluster)가 접근 가능한 상태여야 한다고 한다. 클러스터가 아직 생성되지 않은 상태이므로  해당 eniconfig 에 대한 커스텀 네트워크 리소스 설정 부분을 배제한 다른 tfvars 를 이용하여 배포에 성공하였다.

 

 

 

 

 

What are the major leaders in infrastructure automation technologies?


 

  • AWS CloudFormation: AWS CloudFormation is Amazon Web Services' (AWS) native IaC service that allows users to create and manage AWS resources using JSON or YAML templates.

 

  • Google Cloud Deployment Manager: Similar to CloudFormation, Google Cloud Deployment Manager enables the creation and management of Google Cloud Platform (GCP) resources through configuration files.

 

  • Azure Resource Manager (ARM) Templates: Microsoft Azure's ARM Templates provide IaC capabilities for defining and managing Azure resources.

 

  • Ansible: Ansible is an open-source automation tool that supports IaC for provisioning, configuration management, and application deployment.

 

  • Chef: Chef is another open-source automation platform that enables configuration management and infrastructure automation.

 

  • Puppet: Puppet is a configuration management tool that helps manage the state of IT infrastructure through code.

 

  • Jenkins: Jenkins is an open-source automation server that can be used for continuous integration and continuous deployment (CI/CD) pipelines.

 

  • GitLab CI/CD: GitLab provides built-in CI/CD capabilities for automating the deployment and testing of applications using GitLab's infrastructure.

 

 

A brief description of some of HashiCorp key services


  • Terraform: Terraform is an infrastructure as code (IaC) tool that enables users to define and manage cloud infrastructure using a declarative configuration language. With Terraform, you can create, modify, and destroy infrastructure resources across various cloud providers, data centers, and services, all in a version-controlled and repeatable manner.

 

  • Consul: Consul is a service networking platform that provides features for service discovery, health checking, and key-value storage. It simplifies the management of distributed applications and microservices by enabling them to locate and communicate with each other reliably.

 

  • Vault: Vault is a secrets management tool that securely stores, accesses, and manages sensitive data, such as passwords, tokens, and encryption keys. It ensures that applications and services can access secrets securely without hardcoding or exposing them.

 

  • Nomad: Nomad is a lightweight and flexible job scheduler and orchestrator. It allows users to deploy and manage applications across various infrastructure platforms, including virtual machines, containers, and bare-metal servers.

    Packer: Packer is a tool for creating machine images for various platforms, such as Amazon EC2, Microsoft Azure, and Docker. It automates the process of creating consistent, ready-to-use machine images, ensuring that environments are reproducible and scalable.

    Vagrant: Vagrant is a development environment automation tool that simplifies the setup and configuration of virtual development environments. It allows developers to create and share reproducible development environments easily.

'devops > ETC' 카테고리의 다른 글

Hashcorp Vault with a simple demo  (0) 2024.06.23
Pulumi with a simple demo  (0) 2024.06.23
Istio - service mesh  (2) 2024.06.15
Aqua Security / Trivy  (2) 2024.06.15
Cross Plane 이란  (0) 2024.06.15

+ Recent posts