Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 11 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ task --taskfile https://raw.githubusercontent.com/stuttgart-things/tasks/refs/he
```bash
kubectl apply --server-side -k https://github.com/stuttgart-things/helm/cicd/crds/crossplane

# BY TASKFILE
# BY TASKFILE (IS USING GUM+DAGGER)
export TASK_X_REMOTE_TASKFILES=1
task --taskfile https://raw.githubusercontent.com/stuttgart-things/tasks/refs/heads/main/kubernetes/helm.yaml helmfile-operation #apply+crossplane
```
Expand Down Expand Up @@ -72,61 +72,13 @@ dagger call -m github.com/stuttgart-things/dagger/helm@v0.57.0 \
<details><summary><b>ADD LOCAL CLUSTER AS KUBERNETES PROVIDER (FILEBASED)</b></summary>

```bash
NAMESPACE="crossplane-system"
KUBECONFIG_DIR="$HOME/.kube"

# Select kubeconfig file
KUBECONFIG_FILE=$(ls -1 "$KUBECONFIG_DIR" \
| gum choose --header "Select kubeconfig file")

KUBECONFIG_PATH="$KUBECONFIG_DIR/$KUBECONFIG_FILE"

# Secret name
SECRET_NAME=$(gum input \
--prompt "Secret name: " \
--value "dev")

# Create or update secret (idempotent)
kubectl -n "$NAMESPACE" create secret generic "$SECRET_NAME" \
--from-file=config="$KUBECONFIG_PATH" \
--dry-run=client -o yaml \
| kubectl apply -f -
```

```bash
NAMESPACE="crossplane-system"

CONFIG_NAME=$(gum input \
--prompt "ClusterProviderConfig name: " \
--value "dev")

SECRET_NAME=$(kubectl get secret -n "$NAMESPACE" \
-o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' \
| gum choose --header "Select secret")

SECRET_KEY=$(kubectl get secret "$SECRET_NAME" -n "$NAMESPACE" \
-o json \
| jq -r '.data | keys[]' \
| gum choose --header "Select key from secret '$SECRET_NAME'")

if ! gum confirm "Apply ClusterProviderConfig '$CONFIG_NAME' using $SECRET_NAME:$SECRET_KEY?"; then
echo "Aborted."
exit 0
fi

kubectl apply -f - <<EOF
apiVersion: kubernetes.m.crossplane.io/v1alpha1
kind: ClusterProviderConfig
metadata:
name: $CONFIG_NAME
spec:
credentials:
source: Secret
secretRef:
namespace: $NAMESPACE
name: $SECRET_NAME
key: $SECRET_KEY
EOF
dagger call -m github.com/stuttgart-things/blueprints/crossplane-configuration add-cluster \
--clusterName=in-cluster \
--kubeconfig-cluster file:///home/sthings/.kube/xplane \ --kubeconfig-crossplane-cluster file:///home/sthings/.kube/xplane \
--deploy-to-cluster=false \
--progress plain \
-vv export \
--path=/tmp/xplane
```

</details>
Expand Down Expand Up @@ -154,24 +106,13 @@ task --taskfile https://raw.githubusercontent.com/stuttgart-things/crossplane/re

## CONFIGURATIONS

<details><summary><b>ANSIBLE-RUN</b></summary>

* [SEE-HOW-TO-USE](configurations/ansible-run/README.md)

* INSTALL
<details><summary><b>APPLY CROSSPLANE PACKAGES</b></summary>

```bash
cat <<EOF | kubectl apply -f -
apiVersion: pkg.crossplane.io/v1
kind: Configuration
metadata:
name: ansible-run
spec:
package: ghcr.io/stuttgart-things/crossplane/ansible-run:11.0.0
EOF
export TASK_X_REMOTE_TASKFILES=1
task --taskfile https://raw.githubusercontent.com/stuttgart-things/crossplane/refs/heads/main/Taskfile.yaml create-new-configuration
```

</details>


## DEVELOPMENT
Expand Down
119 changes: 2 additions & 117 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ vars:
CROSSPLANE_PACKAGE_REGISTRY: ghcr.io
DAGGER_CROSSPLANE_MODULE: github.com/stuttgart-things/dagger/crossplane #../dagger/crossplane #github.com/stuttgart-things/dagger/crossplane
DAGGER_CROSSPLANE_MODULE_VERSION: v0.59.0
BLUEPRINT_CROSSPLANE_MODULE: github.com/stuttgart-things/blueprints/crossplane-configuration
BLUEPRINT_CROSSPLANE_MODULE_VERSION: "@v1.40.0"

includes:
git:
Expand All @@ -18,124 +20,7 @@ includes:
taskfile: https://raw.githubusercontent.com/stuttgart-things/tasks/refs/heads/main/configuration/k2n.yaml

tasks:
create-new-configuration:
desc: Interactive wizard-style generation with smart defaults
vars:
BLUEPRINT_CROSSPLANE_MODULE: github.com/stuttgart-things/blueprints/crossplane-configuration
BLUEPRINT_CROSSPLANE_MODULE_VERSION: "@v1.35.0"
cmds:
- |
set -e # Exit on error

gum style --foreground 212 --bold "🚀 Crossplane Configuration Generator"
echo ""

# Step 1: Get name (with validation)
while true; do
NAME=$(gum input --placeholder "e.g., storage-platform" --prompt "📝 Name: ")
if [ -n "$NAME" ]; then
break
else
gum style --foreground 9 "Name cannot be empty. Please try again."
fi
done

# Auto-generate suggested values based on name
GUESSED_KIND=$(echo "$NAME" | awk -F'-' '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1)) tolower(substr($i,2))}}1' OFS='')
GUESSED_SINGULAR=$(echo "$NAME" | sed 's/-//g')
GUESSED_PLURAL="${GUESSED_SINGULAR}s"
GUESSED_CLAIM="${GUESSED_KIND}Claim"

# Step 2: Get Kind with auto-generated default
KIND=$(gum input --placeholder "e.g., $GUESSED_KIND" --prompt "🏷️ Kind (PascalCase): " --value "$GUESSED_KIND")

# Step 3: Get XRD Singular with auto-generated default
XRD_SINGULAR=$(gum input --placeholder "e.g., $GUESSED_SINGULAR" --prompt "📦 XRD Singular (lowercase): " --value "$GUESSED_SINGULAR")

# Step 4: Get XRD Plural with auto-generated default
XRD_PLURAL=$(gum input --placeholder "e.g., $GUESSED_PLURAL" --prompt "📦 XRD Plural (lowercase): " --value "$GUESSED_PLURAL")

# Auto-generate Claim name
CLAIM_NAME="$GUESSED_CLAIM"

# Step 5: Select base output location
echo ""
echo "📁 Select base folder for configurations:"
BASE_FOLDER=$(gum file --directory)
if [ -z "$BASE_FOLDER" ]; then
gum style --foreground 9 "No folder selected. Using current directory."
BASE_FOLDER="."
fi

# Create final output path
OUTPUT_FOLDER="${BASE_FOLDER}/${NAME}"

# Step 6: Preview
echo ""
gum style --border thick --border-foreground 212 --padding "1 2" --margin "1" \
"Configuration Preview" \
"Name: $NAME" \
"Kind: $KIND" \
"XRD Singular: $XRD_SINGULAR" \
"XRD Plural: $XRD_PLURAL" \
"Claim Name: $CLAIM_NAME" \
"Base Folder: $BASE_FOLDER" \
"Output: $OUTPUT_FOLDER"

# Step 7: Confirm generation
echo ""
if gum confirm "Generate configuration?" --affirmative "Yes" --negative "No"; then
echo ""
echo "🚀 Starting generation..."

# Create the output folder if it doesn't exist
mkdir -p "$OUTPUT_FOLDER"

# Check if .configuration-defaults.yaml exists in repo root
DEFAULTS_FILE=".configuration-defaults.yaml"

if [ -f "$DEFAULTS_FILE" ]; then
DEFAULTS_FLAG="--defaults-file ${DEFAULTS_FILE}"
echo "✓ Using defaults file: $DEFAULTS_FILE"
echo ""
else
gum style --foreground 9 "⚠️ Warning: .configuration-defaults.yaml not found in repo root"
if ! gum confirm "Continue without defaults file?"; then
gum style --foreground 9 "❌ Cancelled"
exit 0
fi
DEFAULTS_FLAG=""
echo ""
fi

# Run the generation (show output for debugging)
echo "Running: dagger call -m {{ .BLUEPRINT_CROSSPLANE_MODULE }}{{ .BLUEPRINT_CROSSPLANE_MODULE_VERSION }} \\"
echo " --name \"${NAME}\" \\"
echo " ${DEFAULTS_FLAG} \\"
echo " --variables=\"name=${NAME},kind=${KIND},xrdSingular=${XRD_SINGULAR},xrdPlural=${XRD_PLURAL},claimName=${CLAIM_NAME}\" \\"
echo " export --path=\"${OUTPUT_FOLDER}\""
echo ""

if dagger call -m {{ .BLUEPRINT_CROSSPLANE_MODULE }}{{ .BLUEPRINT_CROSSPLANE_MODULE_VERSION }} create \
--name "${NAME}" \
${DEFAULTS_FLAG} \
--variables="name=${NAME},kind=${KIND},xrdSingular=${XRD_SINGULAR},xrdPlural=${XRD_PLURAL},claimName=${CLAIM_NAME}" \
export --path="${OUTPUT_FOLDER}"; then

echo ""
gum style --foreground 10 --bold "✅ Successfully generated!"
echo "Output location: $OUTPUT_FOLDER"
else
echo ""
gum style --foreground 9 --bold "❌ Generation failed!"
echo "Check the error messages above for details."
exit 1
fi
else
echo ""
gum style --foreground 9 "❌ Cancelled"
exit 0
fi

push-configuration-package:
desc: Push crossplane configuration package
Expand Down
38 changes: 38 additions & 0 deletions cmds.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# COMMANDS/TROUBLESHOOTING

<details><summary><b>DEBUG CROSSPLANE PROVIDER</b></summary>

```bash
# Get provider pods in crossplane-system
kubectl get pods -n crossplane-system

# Check installed providers
kubectl get providers

# Find provider service accounts
kubectl get sa -n crossplane-system | grep provider

# Check provider revision pods
kubectl get pods -n crossplane-system -l pkg.crossplane.io/revision

# Get all service accounts with their pods
kubectl get pods -n crossplane-system -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.serviceAccountName}{"\n"}{end}'

### Quick fix: Grant permissions to all service accounts in crossplane-system
kubectl apply -f - <<EOF
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: provider-kubernetes-admin
subjects:
- kind: ServiceAccount
name: crossplane-contrib-provider-kubernetes-0be7cab050e9
namespace: crossplane-system
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
EOF
```

</details>
22 changes: 22 additions & 0 deletions configurations/infra/network-integration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# MyClaim

This Crossplane Configuration provisions a `NetworkIntegration` Composite Resource Definition (XRD) along with a Composition and an example Claim.

## DEV


```bash
crossplane render examples/claim-kind.yaml \
compositions/cilium.yaml \
examples/functions.yaml \
--include-function-results
```


```bash
crossplane beta trace NetworkIntegration test-cilium
```

```bash
kubectl get releases.helm.m.crossplane.io -A
```
Loading