⚡ Introduction
is an open-source project by AWS that helps you create and manage custom groups of Kubernetes resources. By defining these groups as ResourceGroups, you can deploy multiple resources together in a consistent and controlled way.
How does kro work?
kro uses core Kubernetes primitives to simplify resource grouping and dependency management. When you apply a ResourceGroup to your cluster, kro:
- Verifies the ResourceGroup specification.
- Creates a new Custom Resource Definition (CRD).
- Deploys a dedicated controller to manage the lifecycle of the resources.
ResourceGroups
of this API to deploy resources in a consistent, controlled way. An instance represents your deployed application and contains your configuration values, serving as the single source of truth for your application's desired state.
Example ResourceGroup Instance
Here's an example of how an instance for the SimpleWebApp might look:
apiVersion: kro.run/v1alpha1
kind: SimpleWebApp
metadata:
name: my-web-app
spec:
appName: awesome-app
image: nginx:latest
replicas: 3
Getting Started with kro
Installation
To install kro, you need Helm and kubectl configured for your Kubernetes cluster. Follow these steps:
Fetch the latest release version:
CODEexport KRO_VERSION=$(curl -sL https://api.github.com/repos/awslabs/kro/releases/latest | jq -r '.tag_name | ltrimstr("v")')
Install kro using Helm:
CODEhelm install kro oci://public.ecr.aws/kro/kro --namespace kro --create-namespace --version=${KRO_VERSION}
Verify the installation:
CODEhelm -n kro list
kubectl get pods -n kro
Creating Your First ResourceGroup
Define a ResourceGroup:
Save the following asresourcegroup.yaml:
CODEapiVersion: kro.run/v1alpha1
kind: ResourceGroup
metadata:
name: my-application
spec:
schema:
apiVersion: v1alpha1
kind: Application
spec:
name: string
image: string | default="nginx"
ingress:
enabled: boolean | default=false
status:
deploymentConditions: ${deployment.status.conditions}
availableReplicas: ${deployment.status.availableReplicas}
resources:
- id: deployment
template:
apiVersion: apps/v1
kind: Deployment
metadata:
name: ${schema.spec.name}
spec:
replicas: 3
selector:
matchLabels:
app: ${schema.spec.name}
template:
metadata:
labels:
app: ${schema.spec.name}
spec:
containers:
- name: ${schema.spec.name}
image: ${schema.spec.image}
ports:
- containerPort: 80
- id: service
template:
apiVersion: v1
kind: Service
metadata:
name: ${schema.spec.name}-service
spec:
selector: ${deployment.spec.selector.matchLabels}
ports:
- protocol: TCP
port: 80
targetPort: 80
- id: ingress
includeWhen:
- ${schema.spec.ingress.enabled}
template:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ${schema.spec.name}-ingress
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/healthcheck-path: /health
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}]'
alb.ingress.kubernetes.io/target-group-attributes: stickiness.enabled=true,stickiness.lb_cookie.duration_seconds=60
spec:
rules:
- http:
paths:
- path: "/"
pathType: Prefix
backend:
service:
name: ${service.metadata.name}
port:
number: 80
Apply the ResourceGroup:
CODEkubectl apply -f resourcegroup.yaml
Inspect the ResourceGroup:
CODEkubectl get rg my-application -o wide
Creating an Application Instance
Define an Application instance:
Save the following asinstance.yaml:
CODEapiVersion: kro.run/v1alpha1
kind: Application
metadata:
name: my-application-instance
spec:
name: my-awesome-app
ingress:
enabled: true
Apply the Application instance:
CODEkubectl apply -f instance.yaml
Inspect the Application instance:
CODEkubectl get applications
Inspect the resources:
CODEkubectl get deployments,services,ingresses
Deleting the Application Instance
To clean up resources, delete the Application instance:
kubectl delete application my-application-instance
🌟 Conclusion
kro by AWS simplifies Kubernetes resource management by allowing you to define and manage complex resource configurations as reusable components. Whether you're deploying simple applications or complex multi-service architectures, kro can help streamline your Kubernetes operations.
🌐 Community Participation
Development and discussion are coordinated in the channel.
We welcome questions, suggestions, and contributions from the community! To get involved, check out our contributing guide. For bugs or feature requests, feel free to submit an issue. You’re also invited to join our community.
📚 Documentation
For more detailed information, check out the following resources:
♻️ X/Twitter: for more insights on AWS cloud computing and containers.
↗ Original-Artikel auf dev.to lesenVollständiger Original-BerichtAusführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
SOCIAL SHARE CARD GENERATOR