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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 39 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,46 @@ jobs:
apply-all-yaml:
runs-on: ubuntu-latest

# run a single container k8s control plane:
# couldn't figure how to specify a custom command for the container
# so ended up creating a custom image
services:
k3s:
image: lalyos/k3s:hack
ports:
- 8080:8080
options: >-
--privileged
## run a single container k8s control plane:
## couldn't figure how to specify a custom command for the container
## so ended up creating a custom image
#services:
# k3s:
# image: lalyos/k3s:hack
# ports:
# - 8080:8080
# options: >-
# --privileged

steps:
- uses: actions/checkout@v2

- name: kubectl version
run: |
sleep 5
type kubectl
kubectl version || true | tee apply.txt
kubectl create sa default 2>/dev/null || true
kubectl get sa -A

- name: check all yaml
run: |
for y in [A-Z][a-z]*/**/*.yaml; do
echo === apply: ${y}
if kubectl apply -f $y ;then
kubectl delete -f $y &
else
echo === ERROR: $y
fi
done |& tee apply.txt

- name: upload artifact
uses: actions/upload-artifact@v2
with:
name: apply-test-all-yaml
path: apply.txt

- name: check apply log for error
run: |
if grep -B1 '=== ERROR' apply.txt; then exit 1; fi
# - name: kubectl version
# run: |
# sleep 5
# type kubectl
# kubectl version || true | tee apply.txt
# ls ~/.*
# kubectl create sa default 2>/dev/null || true
# kubectl get sa -A

# - name: check all yaml
# run: |
# for y in [A-Z][a-z]*/**/*.yaml; do
# echo === apply: ${y}
# if kubectl apply -f $y ;then
# kubectl delete -f $y &
# else
# echo === ERROR: $y
# fi
# done |& tee apply.txt

# - name: upload artifact
# uses: actions/upload-artifact@v2
# with:
# name: apply-test-all-yaml
# path: apply.txt

# - name: check apply log for error
# run: |
# if grep -B1 '=== ERROR' apply.txt; then exit 1; fi
2 changes: 1 addition & 1 deletion Deployment/webserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
- -m
- http.server
ports:
- containerPort: 8000
- containerPort: 8000
---
# https://kubernetes.io/docs/concepts/services-networking/service/
apiVersion: v1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
Expand Down
1 change: 1 addition & 0 deletions PodPreset/pod-preset.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: settings.k8s.io/v1alpha1
kind: PodPreset
metadata:
Expand Down
41 changes: 41 additions & 0 deletions ServiceAccount/service-account-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: role-pod-read
namespace: default
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: service-account-rolebinding
namespace: default
subjects:
- kind: ServiceAccount
name: service-account-pod-read
roleRef:
kind: Role
name: role-pod-read
apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: service-account-pod-read
namespace: default
---
apiVersion: v1
kind: Pod
metadata:
name: service-account-pod
namespace: default
spec:
containers:
- command: ["/bin/bash", "-c", "apt update -y -qq && apt install -qq -y curl && curl -s https://kubernetes:443/api/v1/namespaces/default/pods --header \"Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)\" --insecure && sleep 3600"]
image: ubuntu
name: pods-simple-container
serviceAccount: service-account-pod-read