エンベロープ オブジェクト は、Azure Kubernetes Fleet Manager によって定義された Kubernetes カスタム リソースのペアです。これにより、ユーザーは、ハブ クラスターに意図しない副作用を引き起こすことなく、メンバー クラスターへの伝達のためにリソースをパッケージ化できます。
このガイドでは、ハブ クラスターからエンベロープ オブジェクト内の参加メンバー クラスターに一連のリソースを伝達する手順について説明します。
CRD を含むエンベロープ オブジェクト
Fleet では、リソースを伝達するための 2 種類のエンベロープ カスタム リソース定義 (CRD) がサポートされるようになりました。
- ClusterResourceEnvelope: 配置のためにクラスター スコープのリソースをラップするために使用されます。
- ResourceEnvelope: 名前空間スコープのリソースを配置用にラップするために使用されます。
これらの CRD は、ハブ クラスターに意図しない副作用を引き起こすことなく、メンバー クラスターへの伝達のためにリソースをパッケージ化する、より構造化された Kubernetes ネイティブの方法を提供します。
ClusterResourceEnvelope の例
ClusterResourceEnvelopeは、クラスター スコープの他のリソースのみをラップできるクラスター スコープのリソースです。 例えば次が挙げられます。
apiVersion: placement.kubernetes-fleet.io/v1beta1
kind: ClusterResourceEnvelope
metadata:
name: example
data:
"webhook.yaml":
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: guard
webhooks:
- name: guard.example.com
rules:
- operations: ["CREATE"]
apiGroups: ["*"]
apiVersions: ["*"]
resources: ["*"]
clientConfig:
service:
name: guard
namespace: ops
admissionReviewVersions: ["v1"]
sideEffects: None
timeoutSeconds: 10
"clusterrole.yaml":
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: pod-reader
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
ResourceEnvelope の例
名前空間スコープのリソースであるResourceEnvelopeは、名前空間スコープのリソースのみをラップできます。 例えば次が挙げられます。
apiVersion: placement.kubernetes-fleet.io/v1beta1
kind: ResourceEnvelope
metadata:
name: example
namespace: app
data:
"cm.yaml":
apiVersion: v1
kind: ConfigMap
metadata:
name: config
namespace: app
data:
foo: bar
"deploy.yaml":
apiVersion: apps/v1
kind: Deployment
metadata:
name: ingress
namespace: app
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: web
image: nginx
ハブ クラスターからメンバー クラスターへのエンベロープ オブジェクトの伝達
ハブ クラスターにエンベロープ オブジェクトを適用し、 ClusterResourcePlacement オブジェクトを使用して、これらのリソースをハブからメンバー クラスターに伝達します。
ResourceEnvelope を伝達するための ClusterResourcePlacement 仕様の例:
ClusterResourcePlacementをメンバー クラスターに伝達する ResourceEnvelope (CRP) の例を次に示します。ResourceEnvelopeは名前空間スコープであるため、CRP はエンベロープ オブジェクトを含む名前空間を選択するだけで済みます。
apiVersion: placement.kubernetes-fleet.io/v1beta1
kind: ClusterResourcePlacement
metadata:
name: crp-with-envelope
spec:
policy:
clusterNames:
- kind-cluster-1
placementType: PickFixed
resourceSelectors:
- group: ""
kind: Namespace
name: app
version: v1
revisionHistoryLimit: 10
strategy:
type: RollingUpdate
ClusterResourceEnvelope を伝達するための CRP 仕様の例:
ClusterResourcePlacementをメンバー クラスターに伝達する ClusterResourceEnvelope (CRP) の例を次に示します。ClusterResourceEnvelopeはクラスター スコープであるため、ClusterResourcePlacement オブジェクトはエンベロープ オブジェクト自体を選択するだけで済みます。
apiVersion: placement.kubernetes-fleet.io/v1beta1
kind: ClusterResourcePlacement
metadata:
name: crp-with-cluster-envelope
spec:
policy:
clusterNames:
- kind-cluster-1
placementType: PickFixed
resourceSelectors:
- group: placement.kubernetes-fleet.io
kind: ClusterResourceEnvelope
name: example
version: v1beta1
revisionHistoryLimit: 10
strategy:
type: RollingUpdate
エンベロープ リソースの CRP 状態の例:
ClusterResourcePlacementを伝達するResourceEnvelopeの場合、状態には選択した名前空間とエンベロープ オブジェクト自体が含まれますが、エンベロープ内の個々のリソースは含まれません。 状態は次のようになります。
status:
selectedResources:
- group: ""
kind: Namespace
name: app
version: v1
- group: placement.kubernetes-fleet.io
kind: ResourceEnvelope
name: example
namespace: app
version: v1beta1
conditions:
- lastTransitionTime: "2023-11-30T19:54:13Z"
message: found all the clusters needed as specified by the scheduling policy
observedGeneration: 2
reason: SchedulingPolicyFulfilled
status: "True"
type: ClusterResourcePlacementScheduled
- lastTransitionTime: "2023-11-30T19:54:18Z"
message: All 1 cluster(s) are synchronized to the latest resources on the hub cluster
observedGeneration: 2
reason: SynchronizeSucceeded
status: "True"
type: ClusterResourcePlacementSynchronized
- lastTransitionTime: "2023-11-30T19:54:18Z"
message: Successfully applied resources to 1 member clusters
observedGeneration: 2
reason: ApplySucceeded
status: "True"
type: ClusterResourcePlacementApplied
placementStatuses:
- clusterName: kind-cluster-1
conditions:
- lastTransitionTime: "2023-11-30T19:54:13Z"
message: 'Successfully scheduled resources for placement in kind-cluster-1:
picked by scheduling policy'
observedGeneration: 2
reason: ScheduleSucceeded
status: "True"
type: ResourceScheduled
- lastTransitionTime: "2023-11-30T19:54:18Z"
message: Successfully Synchronized work(s) for placement
observedGeneration: 2
reason: WorkSynchronizeSucceeded
status: "True"
type: WorkSynchronized
- lastTransitionTime: "2023-11-30T19:54:18Z"
message: Successfully applied resources
observedGeneration: 2
reason: ApplySucceeded
status: "True"
type: ResourceApplied
注
selectedResourcesセクションでは、伝達されたエンベロープ オブジェクトを具体的に表示します。 エンベロープ オブジェクトに含まれるすべてのリソースを個別に状態に一覧表示するわけではありません。
selectedResourcesの検査時に、名前空間appと ResourceEnvelope exampleが正常に伝達されたことを示します。 ユーザーは、ターゲット クラスターのfailedPlacementsの placementStatus セクションが状態に表示されないようにすることで、エンベロープ オブジェクト内に含まれるリソースの正常な伝達をさらに確認できます。
失敗した ResourceEnvelope リソースを含む CRP 状態の例:
次の例では、placementStatusの kind-cluster-1 セクション内の failedPlacements セクションに、適用できなかったリソースの詳細と、リソースを含むエンベロープ オブジェクトに関する情報が示されています。
status:
conditions:
- lastTransitionTime: "2023-12-06T00:09:53Z"
message: found all the clusters needed as specified by the scheduling policy
observedGeneration: 2
reason: SchedulingPolicyFulfilled
status: "True"
type: ClusterResourcePlacementScheduled
- lastTransitionTime: "2023-12-06T00:09:58Z"
message: All 1 cluster(s) are synchronized to the latest resources on the hub cluster
observedGeneration: 2
reason: SynchronizeSucceeded
status: "True"
type: ClusterResourcePlacementSynchronized
- lastTransitionTime: "2023-12-06T00:09:58Z"
message: Failed to apply manifests to 1 clusters, please check the `failedPlacements` status
observedGeneration: 2
reason: ApplyFailed
status: "False"
type: ClusterResourcePlacementApplied
placementStatuses:
- clusterName: kind-cluster-1
conditions:
- lastTransitionTime: "2023-12-06T00:09:53Z"
message: 'Successfully scheduled resources for placement in kind-cluster-1:
picked by scheduling policy'
observedGeneration: 2
reason: ScheduleSucceeded
status: "True"
type: ResourceScheduled
- lastTransitionTime: "2023-12-06T00:09:58Z"
message: Successfully Synchronized work(s) for placement
observedGeneration: 2
reason: WorkSynchronizeSucceeded
status: "True"
type: WorkSynchronized
- lastTransitionTime: "2023-12-06T00:09:58Z"
message: Failed to apply manifests, please check the `failedPlacements` status
observedGeneration: 2
reason: ApplyFailed
status: "False"
type: ResourceApplied
failedPlacements:
- condition:
lastTransitionTime: "2023-12-06T00:09:53Z"
message: 'Failed to apply manifest: namespaces "app" not found'
reason: AppliedManifestFailedReason
status: "False"
type: Applied
envelope:
name: example
namespace: app
type: ResourceEnvelope
kind: Deployment
name: ingress
namespace: app
version: apps/v1
selectedResources:
- kind: Namespace
name: app
version: v1
- group: placement.kubernetes-fleet.io
kind: ResourceEnvelope
name: example
namespace: app
version: v1beta1
失敗した ClusterResourceEnvelope リソースを含む CRP の状態:
名前空間スコープのリソースと同様に、ClusterResourceEnvelope 内のクラスター スコープリソースも適用に失敗する可能性があります。
status:
conditions:
- lastTransitionTime: "2023-12-06T00:09:53Z"
message: found all the clusters needed as specified by the scheduling policy
observedGeneration: 2
reason: SchedulingPolicyFulfilled
status: "True"
type: ClusterResourcePlacementScheduled
- lastTransitionTime: "2023-12-06T00:09:58Z"
message: Failed to apply manifests to 1 clusters, please check the `failedPlacements` status
observedGeneration: 2
reason: ApplyFailed
status: "False"
type: ClusterResourcePlacementApplied
placementStatuses:
- clusterName: kind-cluster-1
conditions:
- lastTransitionTime: "2023-12-06T00:09:58Z"
message: Failed to apply manifests, please check the `failedPlacements` status
observedGeneration: 2
reason: ApplyFailed
status: "False"
type: ResourceApplied
failedPlacements:
- condition:
lastTransitionTime: "2023-12-06T00:09:53Z"
message: 'Failed to apply manifest: service "guard" not found in namespace "ops"'
reason: AppliedManifestFailedReason
status: "False"
type: Applied
envelope:
name: example
type: ClusterResourceEnvelope
kind: ValidatingWebhookConfiguration
name: guard
group: admissionregistration.k8s.io
version: v1
selectedResources:
- group: placement.kubernetes-fleet.io
kind: ClusterResourceEnvelope
name: example
version: v1beta1