Skip to content

Instantly share code, notes, and snippets.

@haarchri
haarchri / gist:6526d1738611cc79c04e88091dfe074a
Created January 25, 2024 18:01
crossplane-debug-vscode
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
@haarchri
haarchri / gist:e845a2213618f12e663915da53110839
Last active December 5, 2023 22:00
go-function-conditional-keys
- step: addon-keyvault-secrets-provider
functionRef:
name: crossplane-contrib-function-go-templating
input:
apiVersion: gotemplating.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
{{ if and (ne $.observed.resources nil) }}
apiVersion: v1
items:
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: SecurityGroup
metadata:
name: my-db-b9t8p-scfnc
spec:
forProvider:
description: Allow access to PostgreSQL
name: uxp-getting-started
## get all managed resources
kubectl get managed -l crossplane.io/claim-name=test123 -o yaml >> export.yaml
## use only .items[]
cat export.yaml | yq e -P '.items' >> temp.yaml
## create individual files
yq '.[]' temp.yaml -s '"backup_" + .kind +"_"+ .metadata.name'
## add paused annotation
for file in backup* ; do yq eval '.metadata.annotations += {"crossplane.io/paused": "true"}' -i "$file"; done
## apply all files
kubectl apply --dry-run=client $(ls backup*.yml | awk ' { print " -f " $1 } ')
apiVersion: escalation.pagerduty.crossplane.io/v1alpha1
kind: Policy
metadata:
annotations:
meta.upbound.io/example-id: escalation/v1alpha1/policy
labels:
testing.upbound.io/example-name: example
name: example
spec:
forProvider:
@haarchri
haarchri / gist:1e490a715f4aa1e91cf1cc88539ff426
Created August 1, 2023 17:36
debug config for upjet doc generation
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
#!/bin/bash
set -e
## use this script if you what you want to do ;)
## check that crossplane is running as minimum with
## resources:
## limits:
## cpu: 2000m
## memory: 2Gi
#!/bin/bash
set -e
uidpath=$(kubectl get cluster.container.gcp.upbound.io/nodepool -o jsonpath='{.metadata.uid}')
echo $uidpath
kubectl get pods -n crossplane-system | grep "provider-gcp" | awk {'print $1'} | xargs -I% kubectl exec -it % -n crossplane-system -- /bin/bash -c "cd /tmp/$uidpath/; sed -i 's/\"lifecycle\":{\"prevent_destroy\":true},//g' main.tf.json; terraform init; terraform plan"
#!/bin/bash
set -e
export AWS_PAGER=""
CASTAI_API_URL="${CASTAI_API_URL:-https://api.cast.ai}"
kubectl get namespace castai-agent > /dev/null 2>&1
if [ $? -eq 1 ]
then
apiVersion: v1
kind: ServiceAccount
metadata:
name: cleanup-clusteradmissionreports
namespace: kyverno
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cleanup-clusteradmissionreports