본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

클러스터

원문 보기 위키 갱신

GraphQL API로 클러스터를 다루는 일반적인 작업 모음이에요.

Buildkite GraphQL 콘솔로 Buildkite GraphQL API를 시험해 볼 수 있어요. Documentation 탭의 내장 문서도 포함돼요.

클러스터·큐·토큰 관리부터 캐시 레지스트리, 작업·에이전트 조회까지 살펴봐요.

출처: 문서

본문

GraphQL API로 클러스터를 다루는 일반적인 작업 모음이에요.

Buildkite GraphQL 콘솔로 Buildkite GraphQL API를 시험해 볼 수 있어요. Documentation 탭의 내장 문서도 포함돼요.

클러스터 나열하기

조직의 처음 10개 클러스터와 정보 가져오기:

query getClusters {
  organization(slug: "organization-slug") {
    clusters(first: 10) {
      edges {
        node {
          id
          uuid
          color
          description
        }
      }
    }
  }
}

큐 나열하기

특정 클러스터의 처음 10개 클러스터 큐를 가져와요. cluster 쿼리의 id 인자로 클러스터의 UUID를 지정해요:

query getQueues {
  organization(slug: "organization-slug") {
    cluster(id: "cluster-uuid") {
      queues(first: 10) {
        edges {
          node {
            id
            uuid
            key
            description
          }
        }
      }
    }
  }
}

에이전트 토큰 나열하기

특정 클러스터의 처음 10개 에이전트 토큰을 가져와요. cluster 쿼리의 id 인자로 클러스터의 UUID를 지정해요:

query getAgentTokens {
  organization(slug: "organization-slug") {
    cluster(id: "cluster-uuid") {
      agentTokens(first: 10){
        edges{
          node{
            id
            uuid
            description
            allowedIpAddresses
          }
        }
      }
    }
  }
}

🚧 클러스터 token 필드 폐기 예정 ClusterToken 오브젝트의 token 필드는 보안 개선을 위해 폐기 예정이에요. 토큰을 만든 뒤에는 ClusterAgentTokenCreatePayload 오브젝트의 tokenValue 필드를 대신 사용하세요.

캐시 레지스트리 나열하기

📘 공개 프리뷰 캐시 레지스트리 API는 공개 프리뷰로 모든 Buildkite 고객에게 제공돼요.

특정 클러스터의 처음 10개 캐시 레지스트리를 가져와요. cluster 쿼리의 id 인자로 클러스터의 UUID를 지정해요:

query getCacheRegistries {
  organization(slug: "organization-slug") {
    id
    cluster(id: "cluster-uuid") {
      id
      cacheRegistries(first: 10) {
        pageInfo {
          hasNextPage
          endCursor
        }
        edges {
          node {
            id
            uuid
            slug
            name
            description
          }
        }
      }
    }
  }
}

결과는 슬러그 순으로 정렬돼요. hasNextPage가 true면 endCursor를 cacheRegistries의 after 인자로 전달해 다음 페이지를 가져오세요.

캐시 레지스트리의 나열과 관리에는 조직 관리자나 클러스터 maintainer 권한이 필요해요. Enable GraphQL API Access 권한이 선택된 API 접근 토큰을 사용하세요.

쿼리는 Relay 전역 ID(id)와 UUID(uuid)를 모두 반환해요. 아래 mutation에는 조직, 클러스터, 레지스트리의 id 값을 사용하세요. UUID나 슬러그가 아니에요. mutation과 달리 organization.cluster(id:)는 클러스터 UUID를 받아요.

이 API는 캐시 항목이나 에이전트의 save·restore 작업이 아니라 레지스트리 메타데이터와 정책을 관리해요. 캐시 스토어 구성은 웹 인터페이스를 사용하세요. 클러스터의 기본 레지스트리를 선택하려면 웹 인터페이스나 REST API의 Update a cluster 엔드포인트를 사용하세요.

만료일이 있는 에이전트 토큰 만들기

만료일이 있는 에이전트 토큰을 만들어요. 만료일은 Buildkite 인터페이스에 표시되고 다른 Buildkite API 호출로 바꿀 수 없어요.

mutation createToken {
  clusterAgentTokenCreate(input: {
    organizationId: "organization-id",
    description: "A token with an expiration date",
    clusterId:"cluster-id",
    expiresAt: "2026-01-01T00:00:00Z"
  }) {
    tokenValue
  }
}

에이전트 토큰 폐기하기

먼저 에이전트 토큰 목록에서 에이전트 토큰의 ID를, 이어서 Buildkite 조직의 ID를 얻으세요. 그다음 이 ID 값들로 에이전트 토큰을 폐기해요:

mutation revokeClusterAgentToken {
  clusterAgentTokenRevoke(input: {
    id: "agent-token-id"
    organizationId: "organization-id"
    }) {
    clientMutationId
    deletedClusterAgentTokenId
  }
}

자체 호스팅 큐 만들기

클러스터에 새 _자체 호스팅 큐_를 만들어요. 자체 호스팅 큐는 직접 호스팅하는 에이전트를 위해 만든 큐예요.

mutation {
  clusterQueueCreate(input: {
    organizationId: "organization-id",
    clusterId: "cluster-id",
    key: "default",
    description: "The default queue for this cluster."
  }) {
    clusterQueue {
      id
      uuid
      key
      description
      hosted
      createdBy {
        id
        uuid
        name
      }
      cluster {
        id
        uuid
        name
      }
    }
  }
}

Buildkite 호스팅 큐 만들기

Buildkite 호스팅 큐를 만드는 방법은 이 cookbook의 Hosted agents 페이지의 Create a Buildkite hosted queue에서 더 알아보세요.

큐 업데이트하기

기존 큐를 업데이트해요.

mutation {
  clusterQueueUpdate(input: {
    organizationId: "organization-id",
    id: "cluster-id",
    description: "The default queue for this cluster, but this time with a modified description.",
  }) {
    clusterQueue {
      id
      uuid
      key
      description
      hosted
      createdBy {
        id
        uuid
        name
      }
      cluster {
        id
        uuid
        name
      }
    }
  }
}

Buildkite 호스팅 큐의 인스턴스 셰이프를 업데이트하는 방법은 이 cookbook의 Hosted agents 페이지의 Change the instance shape of a Buildkite hosted queue's agents에서 더 알아보세요.

큐 삭제하기

큐의 ID로 기존 큐를 삭제해요.

mutation {
  clusterQueueDelete(input: {
    organizationId: "organization-id",
    id: "queue-id"
  }) {
    deletedClusterQueueId
  }
}

캐시 레지스트리 만들기

클러스터에 다른 캐시 레지스트리를 만들어요. clusterId 인자로 클러스터의 ID를 지정해요:

mutation createCacheRegistry {
  cacheRegistryCreate(input: {
    organizationId: "organization-id",
    clusterId: "cluster-id",
    name: "Build cache",
    description: "Compiler output cache"
  }) {
    cacheRegistry {
      id
      uuid
      slug
      name
      description
      cluster {
        id
        uuid
      }
    }
  }
}

새 레지스트리는 에이전트 관리 저장소를 사용해요. 캐시 스토어는 이 API로 설정할 수 없어요.

policy 인자를 캐시 정책 구성하기에서 설명하는 구조화된 정책 문서의 JSON 인코딩 문자열로 설정하세요. 예를 들어 save와 restore를 모두 허용하려면 create 입력에 이 인자를 추가해요:

policy: "{\"save\":{\"scopes\":{}},\"restore\":{\"scopes\":[{}]},\"rules\":[{\"effect\":\"allow\",\"action\":\"save\"},{\"effect\":\"allow\",\"action\":\"restore\"}]}"

GraphQL JSON 타입은 JSON 인코딩 문자열을 받아요. 오브젝트 리터럴이나 직접 작성한 YAML이 아니에요. API는 정책을 검증·정규화해요. 반환되는 policy 필드도 JSON 인코딩 문자열이고, 룰 동작은 배열로 정규화돼요.

레지스트리를 만들 때 policy를 생략하거나 null로 설정하면 기본 무제한 정책이 사용돼요.

캐시 레지스트리 업데이트하기

기존 캐시 레지스트리의 속성을 업데이트해요. id 인자로 레지스트리의 Relay 전역 ID를 지정하고, 생략한 속성은 그대로 유지돼요:

mutation updateCacheRegistry {
  cacheRegistryUpdate(input: {
    organizationId: "organization-id",
    id: "cache-registry-id",
    description: "Updated compiler output cache"
  }) {
    cacheRegistry {
      id
      uuid
      slug
      name
      description
    }
  }
}

policy를 제공하면 중첩 속성을 병합하는 게 아니라 전체 정책을 대체해요. policy를 null로 설정해 지우면 save와 restore가 거부돼요. 생성과 달리 null로 업데이트하는 것은 기본 무제한 정책을 적용하지 않아요.

name을 바꾸면 레지스트리의 슬러그가 다시 생성돼요. description, emoji, color를 null로 설정해 지울 수 있어요. 레지스트리의 UUID와 캐시 스토어는 이 API로 바꿀 수 없어요.

캐시 레지스트리 삭제하기

레지스트리의 GraphQL ID로 기존 캐시 레지스트리를 삭제해요:

mutation deleteCacheRegistry {
  cacheRegistryDelete(input: {
    organizationId: "organization-id",
    id: "cache-registry-id"
  }) {
    deletedCacheRegistryId
  }
}

클러스터의 기본 캐시 레지스트리는 삭제할 수 없어요. 먼저 웹 인터페이스나 REST API의 Update a cluster 엔드포인트로 다른 기본 레지스트리를 선택하세요.

특정 큐의 작업 나열하기

클러스터의 특정 큐 안의 작업을 얻으려면 jobs 쿼리의 clusterQueue 인자를 사용하고, 작업을 필터링할 큐의 ID를 전달하세요:

query getQueueJobs {
  organization(slug: "organization-slug") {
    jobs(first: 10, clusterQueue: "cluster-queue-id") {
      edges {
        node {
          ... on JobTypeCommand {
            id
            state
            label
            url
            build {
              number
            }
            pipeline {
              name
            }
          }
        }
      }
    }
  }
}

클러스터의 특정 큐 안에서 특정 상태의 작업을 얻으려면 jobs 쿼리에서 clusterQueue 인자로 큐의 ID를, state 인자로 하나 이상의 JobStates를 지정해요:

query getQueueJobsByJobState {
  organization(slug: "organization-slug") {
    jobs(
      first: 10,
      clusterQueue: "cluster-queue-id",
      state: [WAITING, BLOCKED]
    ){
      edges {
        node {
          ... on JobTypeCommand {
            id
            state
            label
            url
            build {
              number
            }
            pipeline {
              name
            }
          }
        }
      }
    }
  }
}

클러스터의 에이전트 나열하기

클러스터 안의 처음 10개 에이전트를 가져오려면 agents 쿼리의 cluster 인자를 사용하고, 클러스터의 ID를 전달하세요:

query getClusterAgents {
   organization(slug:"organization-slug") {
    agents(first: 10, cluster: "cluster-id") {
      edges {
        node {
          name
          hostname
          version
          clusterQueue{
            uuid
            id
          }
        }
      }
    }
  }
}

큐의 에이전트 나열하기

클러스터의 특정 큐 안의 처음 10개 에이전트를 가져오려면 agents 쿼리의 clusterQueue 인자를 지정하고, 클러스터 큐의 ID를 전달하세요:

query getQueueAgents {
   organization(slug:"organization-slug") {
    agents(first: 10, clusterQueue: "cluster-queue-id") {
      edges {
        node {
          name
          hostname
          version
          id
          clusterQueue{
            id
            uuid
          }
        }
      }
    }
  }
}

파이프라인을 클러스터와 연결하기

먼저 파이프라인과 연결하려는 클러스터 ID를 얻으세요. 다음으로 파이프라인의 ID를 얻으세요. 그다음 이 ID들로 파이프라인을 아카이브해요:

mutation AssociatePipelineWithCluster {
  pipelineUpdate(input:{id: "pipeline-id" clusterId: "cluster-id"}) {
    pipeline {
      cluster {
        name
        id
      }
    }
  }
}

더 알아보기 (Learn more)

클러스터 cookbook은 큐·토큰·캐시 레지스트리 관리를 GraphQL로 자동화하는 실전 쿼리 모음이에요. Relay 전역 ID와 UUID의 구분만 조심하면 바로 쓸 수 있어요.