# Build and deploy
make deploy
# Verify deployment
kubectl get deployment -n mynginx-controller-system# examples/basic-mynginx.yaml
apiVersion: webapp.mynginx.amandahla.xyz/v1
kind: MyNginx
metadata:
name: my-nginx-sample
namespace: default
spec:
replicas: 3kubectl apply -f examples/basic-mynginx.yaml
kubectl get mynginx
kubectl get deployment# examples/simple.yaml
apiVersion: webapp.mynginx.amandahla.xyz/v1
kind: MyNginx
metadata:
name: simple-nginx
spec:
replicas: 2
---
# Check the created deployment
# kubectl get deployment simple-nginx# examples/with-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: my-html-content
data:
index.html: |
<!DOCTYPE html>
<html>
<head><title>My Custom Page</title></head>
<body>
<h1>Hello from MyNginx Controller!</h1>
<p>This content comes from a ConfigMap.</p>
</body>
</html>
---
apiVersion: webapp.mynginx.amandahla.xyz/v1
kind: MyNginx
metadata:
name: custom-content-nginx
spec:
replicas: 1
configMapName: my-html-content # Not yet implemented# examples/with-tls.yaml
apiVersion: v1
kind: Secret
metadata:
name: nginx-tls
type: kubernetes.io/tls
data:
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0t... # base64 encoded cert
tls.key: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0t... # base64 encoded key
---
apiVersion: webapp.mynginx.amandahla.xyz/v1
kind: MyNginx
metadata:
name: secure-nginx
spec:
replicas: 2
secretName: nginx-tls # Not yet implemented# examples/complete.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: app-content
data:
index.html: |
<!DOCTYPE html>
<html>
<head><title>Secure App</title></head>
<body>
<h1>Secure Application</h1>
<p>Served over HTTPS with custom content!</p>
</body>
</html>
---
apiVersion: v1
kind: Secret
metadata:
name: app-tls
type: kubernetes.io/tls
stringData:
tls.crt: |
-----BEGIN CERTIFICATE-----
# Your certificate here
-----END CERTIFICATE-----
tls.key: |
-----BEGIN PRIVATE KEY-----
# Your private key here
-----END PRIVATE KEY-----
---
apiVersion: webapp.mynginx.amandahla.xyz/v1
kind: MyNginx
metadata:
name: complete-app
spec:
replicas: 3
configMapName: app-content # Not yet implemented
secretName: app-tls # Not yet implemented# Run controller locally (requires kubeconfig)
make run
# In another terminal, apply test resources
kubectl apply -f examples/basic-mynginx.yaml
# Watch logs for reconciliation# After making code changes
make test
# Test deployment creation
kubectl apply -f examples/basic-mynginx.yaml
kubectl describe deployment simple-nginx
# Test deletion and cleanup
kubectl delete mynginx simple-nginx
# Should clean up deployment due to finalizer# Check controller logs
kubectl logs -f deployment/mynginx-controller-manager -n mynginx-controller-system
# Check resource status
kubectl describe mynginx my-nginx-sample
# Check created deployment
kubectl describe deployment my-nginx-sampleDeploy static websites with configurable scaling:
apiVersion: webapp.mynginx.amandahla.xyz/v1
kind: MyNginx
metadata:
name: website-prod
spec:
replicas: 5Quick nginx instances for testing:
apiVersion: webapp.mynginx.amandahla.xyz/v1
kind: MyNginx
metadata:
name: dev-test
spec:
replicas: 1With TLS termination and custom content:
# When ConfigMap/Secret features are implemented
apiVersion: webapp.mynginx.amandahla.xyz/v1
kind: MyNginx
metadata:
name: lb-frontend
spec:
replicas: 3
configMapName: frontend-config
secretName: frontend-tls# List all MyNginx resources
kubectl get mynginx
# Detailed view
kubectl describe mynginx <name>
# Check associated deployments
kubectl get deployment -l app=mynginx# Scale up/down by editing the resource
kubectl patch mynginx my-nginx-sample -p '{"spec":{"replicas":5}}'
# Or edit directly
kubectl edit mynginx my-nginx-sample# Delete specific resource
kubectl delete mynginx my-nginx-sample
# Delete all MyNginx resources
kubectl delete mynginx --all
# Uninstall controller
make undeploy- Check controller logs
- Verify RBAC permissions
- Check CRD is properly installed
- Check deployment events:
kubectl describe deployment <name> - Check pod logs:
kubectl logs <pod-name> - Verify image availability
- Check controller manager logs
- Verify Kubernetes API compatibility
- Check for resource conflicts