forked from sixeyed/kiamol
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
128 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
*.box | ||
*.tgz | ||
.serverless/ | ||
.vagrant/ | ||
packer_cache/ | ||
builds/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
$controller='ingress-nginx-controller' | ||
$ns='kiamol-ingress-nginx' | ||
$ip=$(kubectl get svc $controller -o jsonpath='{.status.loadBalancer.ingress[0].*}' -n $ns) | ||
if ($ip -eq 'localhost') { | ||
$ip='127.0.0.1' | ||
} | ||
|
||
Add-Content -Value "$ip todo.kiamol.local$([Environment]::NewLine)$ip api.todo.kiamol.local" -Path C:/windows/system32/drivers/etc/hosts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
CONTROLLER='ingress-nginx-controller' | ||
NS='kiamol-ingress-nginx' | ||
IP=$(kubectl get svc $CONTROLLER -o jsonpath='{.status.loadBalancer.ingress[0].*}' -n $NS) | ||
if [ "$IP" = "localhost" ]; then | ||
IP='127.0.0.1' | ||
fi | ||
|
||
echo "\n$IP todo.kiamol.local\n$IP api.todo.kiamol.local" | sudo tee -a /etc/hosts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#using node to match base image for serverless cli | ||
FROM node:12 | ||
|
||
ENV KUBELESS_VERSION="v1.0.7" \ | ||
KUBERNETES_VERSION="1.18.5" | ||
|
||
RUN curl -LO https://github.com/kubeless/kubeless/releases/download/${KUBELESS_VERSION}/kubeless_linux-amd64.zip && \ | ||
unzip kubeless_linux-amd64.zip && \ | ||
rm -f kubeless_linux-amd64.zip && \ | ||
chmod +x bundles/kubeless_linux-amd64/kubeless && \ | ||
mv bundles/kubeless_linux-amd64/kubeless /usr/local/bin/ | ||
|
||
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl && \ | ||
chmod +x kubectl && \ | ||
mv kubectl /usr/local/bin/ | ||
|
||
COPY start.sh / | ||
RUN chmod +x /start.sh | ||
CMD /start.sh | ||
WORKDIR /kiamol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
# set up access to Kube API | ||
kubectl config set-cluster default --server=https://kubernetes.default --certificate-authority=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt | ||
kubectl config set-context default --cluster=default | ||
kubectl config set-credentials user --token=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) | ||
kubectl config set-context default --user=user | ||
kubectl config use-context default | ||
|
||
cd / | ||
git clone https://github.com/sixeyed/kiamol | ||
|
||
while true; do sleep 1000; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package ch21.net.kiamol; | ||
package io.kubeless; | ||
|
||
import io.kubeless.Event; | ||
import io.kubeless.Context; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import json | ||
|
||
def handler(event, context): | ||
new_item = json.loads(event.data) | ||
print(f"AUDIT @ {new_item['Item']['DateAdded']}: {new_item['Item']['Item']}") | ||
def handler(event, context): | ||
print(f"AUDIT @ {event['data']['Item']['DateAdded']}: {event['data']['Item']['Item']}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: kubeless.io/v1beta1 | ||
kind: CronJobTrigger | ||
metadata: | ||
finalizers: | ||
- kubeless.io/cronjobtrigger | ||
labels: | ||
created-by: kubeless | ||
name: todo-mutating-handler | ||
namespace: default | ||
spec: | ||
function-name: todo-mutating-handler | ||
schedule: '*/1 * * * *' | ||
|
||
# finalizers help with clean-up tasks - see | ||
# https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#finalizers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: kubeless-cli | ||
labels: | ||
kiamol: ch21 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: kubeless-cli | ||
labels: | ||
kiamol: ch21 | ||
spec: | ||
serviceAccountName: kubeless-cli | ||
containers: | ||
- name: kubeless-cli | ||
image: kiamol/ch21-kubeless-cli | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: kubeless-cli | ||
labels: | ||
kiamol: ch21 | ||
subjects: | ||
- kind: ServiceAccount | ||
name: kubeless-cli | ||
namespace: default | ||
roleRef: | ||
kind: ClusterRole | ||
name: cluster-admin # tsk | ||
apiGroup: rbac.authorization.k8s.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import json | ||
|
||
def handler(event, context): | ||
new_item = json.loads(event.data) | ||
print(f"AUDIT @ {new_item['Item']['DateAdded']}: {new_item['Item']['Item']}") | ||
def handler(event, context): | ||
print(f"AUDIT @ {event['data']['Item']['DateAdded']}: {event['data']['Item']['Item']}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,4 @@ spec: | |
- port: 5432 | ||
targetPort: 5432 | ||
selector: | ||
app: todo-db | ||
type: LoadBalancer | ||
app: todo-db |