Skip to content

Commit f2ec371

Browse files
authored
Merge branch 'kubernetes-sigs:main' into docsaurs_mermaid
2 parents 8843961 + 6043c4a commit f2ec371

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2451
-238
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
254254

255255
.PHONY: deploy-kind
256256
deploy-kind: export KO_DOCKER_REPO=kind.local
257-
deploy-kind: ko
257+
deploy-kind: ko ## Deploy kro to a kind cluster
258258
$(KIND) delete clusters ${KIND_CLUSTER_NAME} || true
259259
$(KIND) create cluster --name ${KIND_CLUSTER_NAME}
260260
$(KUBECTL) --context kind-$(KIND_CLUSTER_NAME) create namespace kro-system

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
[![Go Report Card](https://goreportcard.com/badge/github.com/kubernetes-sigs/kro)](https://goreportcard.com/report/github.com/kubernetes-sigs/kro)
5-
[![unit tests](https://github.com/kubernetes-sigs/kro/actions/workflows/unit-tests.yaml/badge.svg)](https://github.com/kubernetes-sigs/kro/actions/workflows/unit-tests.yaml)
65
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/kubernetes-sigs/kro)
76
![GitHub License](https://img.shields.io/github/license/kubernetes-sigs/kro)
87
![GitHub Repo stars](https://img.shields.io/github/stars/kubernetes-sigs/kro)

api/v1alpha1/resourcegraphdefinition_types.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ type Schema struct {
7070
// that the resourcegraphdefinition is managing. This is adhering to the
7171
// SimpleSchema spec.
7272
Status runtime.RawExtension `json:"status,omitempty"`
73-
// Validation is a list of validation rules that are applied to the
74-
// resourcegraphdefinition.
75-
Validation []Validation `json:"validation,omitempty"`
73+
7674
// AdditionalPrinterColumns defines additional printer columns
7775
// that will be passed down to the created CRD. If set, no
7876
// default printer columns will be added to the created CRD,
@@ -83,15 +81,11 @@ type Schema struct {
8381
AdditionalPrinterColumns []extv1.CustomResourceColumnDefinition `json:"additionalPrinterColumns,omitempty"`
8482
}
8583

86-
type Validation struct {
87-
Expression string `json:"expression,omitempty"`
88-
Message string `json:"message,omitempty"`
89-
}
90-
9184
type ExternalRefMetadata struct {
9285
// +kubebuilder:validation:Required
9386
Name string `json:"name,omitempty"`
94-
// +kubebuilder:validation:Required
87+
// Namespace of the external resource. optional, if empty uses instance namespace
88+
// +kubebuilder:validation:Optional
9589
Namespace string `json:"namespace,omitempty"`
9690
}
9791

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/controller/main.go

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"os"
2020
"time"
2121

22-
"go.uber.org/zap/zapcore"
2322
extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2423
"k8s.io/apimachinery/pkg/runtime"
2524
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -51,14 +50,6 @@ func init() {
5150
// +kubebuilder:scaffold:scheme
5251
}
5352

54-
type customLevelEnabler struct {
55-
level int
56-
}
57-
58-
func (c customLevelEnabler) Enabled(lvl zapcore.Level) bool {
59-
return -int(lvl) <= c.level
60-
}
61-
6253
func main() {
6354
var (
6455
metricsAddr string
@@ -78,9 +69,8 @@ func main() {
7869
queueMaxRetries int
7970
gracefulShutdownTimeout time.Duration
8071
// var dynamicControllerDefaultResyncPeriod int
81-
logLevel int
82-
qps float64
83-
burst int
72+
qps float64
73+
burst int
8474
)
8575

8676
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8078", "The address the metric endpoint binds to.")
@@ -119,22 +109,19 @@ func main() {
119109
"interval at which the controller will re list resources even with no changes, in seconds.")
120110
flag.IntVar(&queueMaxRetries, "dynamic-controller-default-queue-max-retries", 20,
121111
"maximum number of retries for an item in the queue will be retried before being dropped")
122-
// log level flags
123-
flag.IntVar(&logLevel, "log-level", 10, "The log level verbosity. 0 is the least verbose, 5 is the most verbose.")
124112
// qps and burst
125113
flag.Float64Var(&qps, "client-qps", 100, "The number of queries per second to allow")
126114
flag.IntVar(&burst, "client-burst", 150,
127115
"The number of requests that can be stored for processing before the server starts enforcing the QPS limit")
128116

129-
flag.Parse()
130-
131117
opts := zap.Options{
132118
Development: true,
133-
Level: customLevelEnabler{level: logLevel},
134-
TimeEncoder: zapcore.ISO8601TimeEncoder,
135119
}
136-
rootLogger := zap.New(zap.UseFlagOptions(&opts))
120+
opts.BindFlags(flag.CommandLine)
137121

122+
flag.Parse()
123+
124+
rootLogger := zap.New(zap.UseFlagOptions(&opts))
138125
ctrl.SetLogger(rootLogger)
139126

140127
set, err := kroclient.NewSet(kroclient.Config{
@@ -171,7 +158,6 @@ func main() {
171158
// if you are doing or is intended to do any operation such as perform cleanups
172159
// after the manager stops then its usage might be unsafe.
173160
LeaderElectionReleaseOnCancel: false,
174-
Logger: rootLogger,
175161
})
176162
if err != nil {
177163
setupLog.Error(err, "unable to start manager")

docs/developer-getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ To test and run the project with your local changes, follow these steps to set u
2929

3030
4. Run the kro Controller Locally: Execute the controller with your changes:
3131
```bash
32-
go run ./cmd/controller --log-level 2
32+
go run ./cmd/controller --zap-log-level=info
3333
```
3434
This will connect to the default Kubernetes context in your local kubeconfig (`~/.kube/config`). Ensure the context is pointing to your local cluster.
3535

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
# Dogs vs Cats Voting App
2+
3+
A multi-tier voting application demonstrating Kro's resource composition capabilities with AWS services.
4+
5+
> **Note**: This example composes multiple reusable components. Each component can also be deployed independently. See the [Component Dependencies](#component-dependencies) section below.
6+
7+
## Architecture
8+
9+
This example showcases a complete voting application composed of reusable components:
10+
11+
- **Vote App**: Frontend for casting votes (Python/Flask)
12+
- **Result App**: Results dashboard (Node.js)
13+
- **Worker App**: Processes votes from Redis to PostgreSQL (Java)
14+
- **RDS PostgreSQL**: Stores voting results
15+
- **ElastiCache Serverless**: Caches votes
16+
- **Ingress**: AWS Load Balancer Controller with ALB
17+
18+
## Component Dependencies
19+
20+
This example uses the following reusable components:
21+
22+
- [../../kubernetes/dogsvscats/vote-app/](../../kubernetes/dogsvscats/vote-app/) - Vote frontend
23+
- [../../kubernetes/dogsvscats/result-app/](../../kubernetes/dogsvscats/result-app/) - Results dashboard
24+
- [../../kubernetes/dogsvscats/worker-app/](../../kubernetes/dogsvscats/worker-app/) - Vote processor
25+
- [../rds-postgres/](../rds-postgres/) - PostgreSQL database
26+
- [../elasticache-serverless/](../elasticache-serverless/) - Redis cache
27+
28+
## Prerequisites
29+
30+
- EKS cluster with AWS Load Balancer Controller installed
31+
- Kro installed and running
32+
- AWS ACK controllers for EC2, RDS, and ElastiCache
33+
- VPC with private subnets
34+
35+
Following is a way to deploy EKS cluster that covers all the above prerequisites:
36+
37+
Uses the workshop bootstrap Terraform that creates an EKS cluster (Auto Mode), KRO, ACK add-ons, and ALB Controller.
38+
39+
```bash
40+
# Clone the workshop bootstrap and apply
41+
git clone https://github.com/aws-samples/krmops-on-eks-workshop.git
42+
cd krmops-on-eks-workshop/kro-and-ack/bootstrap/terraform
43+
44+
# Set your variables
45+
export AWS_REGION=ap-southeast-2
46+
export CLUSTER_NAME=agentcore-demo
47+
48+
terraform init
49+
terraform apply -auto-approve \
50+
-var="region=${AWS_REGION}" \
51+
-var="cluster_name=${CLUSTER_NAME}"
52+
53+
## Create ResourceGraphDefinitions
54+
55+
Change directory to `examples`:
56+
57+
```
58+
cd examples/
59+
```
60+
61+
Apply the component RGs first:
62+
63+
```bash
64+
# Apply Kubernetes app components
65+
kubectl apply -f kubernetes/dogsvscats/vote-app/rg.yaml
66+
kubectl apply -f kubernetes/dogsvscats/result-app/rg.yaml
67+
kubectl apply -f kubernetes/dogsvscats/worker-app/rg.yaml
68+
69+
# Apply AWS infrastructure components
70+
kubectl apply -f aws/rds-postgres/rg.yaml
71+
kubectl apply -f aws/elasticache-serverless/rg.yaml
72+
```
73+
74+
Apply the main composed RG:
75+
76+
```bash
77+
kubectl apply -f aws/dogsvscats-appstack/dogsvscats-rg.yaml
78+
```
79+
80+
Validate the RGs statuses are Active:
81+
82+
```
83+
kubectl get rgd
84+
```
85+
86+
Expected result:
87+
88+
```
89+
NAME APIVERSION KIND STATE AGE
90+
dogsvscats-app.kro.run v1alpha1 DogsvsCatsApp Active 1m
91+
elasticache-serverless.kro.run v1alpha1 ElastiCacheServerless Active 2m
92+
rds-postgres.kro.run v1alpha1 RDSPostgres Active 2m
93+
result-app.kro.run v1alpha1 ResultApp Active 2m
94+
vote-app.kro.run v1alpha1 VoteApp Active 2m
95+
worker-app.kro.run v1alpha1 WorkerApp Active 2m
96+
```
97+
98+
## Create an Instance of kind DogsvsCatsApp
99+
100+
Create environment variables for your infrastructure:
101+
102+
```
103+
export WORKLOAD_NAME="dogsvscats-voting-app"
104+
export VPC_ID="vpc-xxxxxxxxx"
105+
export SUBNET_IDS='"subnet-xxxxxxxxx", "subnet-yyyyyyyyy", "subnet-zzzzzzzzz"'
106+
```
107+
108+
Validate the variables are populated:
109+
110+
```
111+
echo $WORKLOAD_NAME
112+
echo $VPC_ID
113+
echo $SUBNET_IDS
114+
```
115+
116+
Run the following command to replace the variables in `instance-template.yaml` and create `instance.yaml`:
117+
118+
```shell
119+
envsubst < "dogsvscats-appstack/instance-template.yaml" > "dogsvscats-appstack/instance.yaml"
120+
```
121+
122+
Apply the `dogsvscats-appstack/instance.yaml`:
123+
124+
```
125+
kubectl apply -f dogsvscats-appstack/instance.yaml
126+
```
127+
128+
Validate instance status:
129+
130+
```
131+
kubectl get dogsvscatsapp dogsvscats-voting-app
132+
```
133+
134+
Expected result:
135+
136+
```
137+
NAME STATE SYNCED AGE
138+
dogsvscats-voting-app ACTIVE True 5m
139+
```
140+
141+
## Validate the app is working
142+
143+
Get the URLs:
144+
145+
```
146+
kubectl get dogsvscatsapp dogsvscats-voting-app
147+
```
148+
149+
This will display both the Vote App and Result App URLs in the output.
150+
151+
Navigate to the vote URL to cast votes, then check the result URL to see the results.
152+
153+
## Clean votes for demo
154+
155+
Reset votes between demos:
156+
157+
```bash
158+
./dogsvscats/scripts/clean-votes.sh
159+
```
160+
161+
## What This Example Demonstrates
162+
163+
1. **Component Composition**: Building complex applications from reusable components
164+
2. **Cross-namespace References**: Kubernetes components referencing AWS infrastructure
165+
3. **Status Propagation**: Passing endpoints and connection details between components
166+
4. **Conditional Resources**: Ingress resources created based on configuration
167+
5. **Multi-cloud Patterns**: Separating cloud-agnostic apps from cloud-specific infrastructure
168+
169+
## Clean up
170+
171+
Remove the instance:
172+
173+
```
174+
kubectl delete dogsvscatsapp dogsvscats-voting-app
175+
```
176+
177+
Remove the ResourceGraphDefinitions:
178+
179+
```bash
180+
# Remove main composed RG
181+
kubectl delete rgd dogsvscats-app.kro.run
182+
183+
# Remove component RGs
184+
kubectl delete rgd vote-app.kro.run result-app.kro.run worker-app.kro.run
185+
kubectl delete rgd rds-postgres.kro.run elasticache-serverless.kro.run
186+
```

0 commit comments

Comments
 (0)