kubeless installers
This commit is contained in:
parent
40a2f5dbe3
commit
babc8b83d3
@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
IP=$1
|
||||
sed "/ExecStart/ s/$/ --insecure-registry=$IP/" /lib/systemd/system/docker.service > /lib/systemd/system/tmp
|
||||
mv /lib/systemd/system/tmp /lib/systemd/system/docker.service
|
||||
systemctl daemon-reload
|
||||
systemctl restart docker.service
|
||||
docker run -d -p 5000:5000 --restart=always --name registry registry:2
|
@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#Install riff cli
|
||||
curl -Lo riff-linux-amd64.tgz https://github.com/projectriff/cli/releases/download/v0.4.0/riff-linux-amd64.tgz
|
||||
tar xvzf riff-linux-amd64.tgz
|
||||
mv riff /usr/local/bin/
|
||||
|
||||
#Install riff
|
||||
helm repo add projectriff https://projectriff.storage.googleapis.com/charts/releases
|
||||
helm repo update
|
||||
|
||||
helm install projectriff/istio --name istio --version 0.4.x --namespace istio-system --set gateways.istio-ingressgateway.type=NodePort --wait
|
||||
helm install projectriff/riff --name riff --version 0.4.x --set knative.enabled=true
|
||||
|
||||
#Verify Install
|
||||
riff doctor
|
24
deploy/kubeless_setup.sh
Normal file
24
deploy/kubeless_setup.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
git clone https://github.com/kubernetes-incubator/metrics-server.git
|
||||
sed -i '34i\ command:\' metrics-server/deploy/1.8+/metrics-server-deployment.yaml
|
||||
sed -i '35i\ - /metrics-server\' metrics-server/deploy/1.8+/metrics-server-deployment.yaml
|
||||
sed -i '36i\ - --kubelet-insecure-tls\' metrics-server/deploy/1.8+/metrics-server-deployment.yaml
|
||||
kubectl create -f metrics-server/deploy/1.8+/
|
||||
|
||||
RELEASE=$(curl -s https://api.github.com/repos/kubeless/kubeless/releases/latest | grep tag_name | cut -d '"' -f 4)
|
||||
kubectl create ns kubeless
|
||||
kubectl create -f https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless-$RELEASE.yaml
|
||||
#kubectl create -f https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless-non-rbac-$RELEASE.yaml
|
||||
|
||||
apt install -y unzip
|
||||
|
||||
#kubeless command
|
||||
OS=$(uname -s| tr '[:upper:]' '[:lower:]')
|
||||
curl -OL https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless_$OS-amd64.zip && \
|
||||
unzip kubeless_$OS-amd64.zip && \
|
||||
sudo mv bundles/kubeless_$OS-amd64/kubeless /usr/local/bin/
|
||||
|
||||
#Ingress nginx
|
||||
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml
|
||||
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/baremetal/service-nodeport.yaml
|
@ -1,23 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#Gen certificates
|
||||
mkdir -p certs
|
||||
cd certs
|
||||
CERT_DIR=$PWD
|
||||
openssl genrsa -des3 -passout pass:x -out dashboard.pass.key 2048
|
||||
openssl rsa -passin pass:x -in dashboard.pass.key -out dashboard.key
|
||||
rm dashboard.pass.key
|
||||
openssl req -new -key dashboard.key -out dashboard.csr -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com"
|
||||
openssl x509 -req -sha256 -days 365 -in dashboard.csr -signkey dashboard.key -out dashboard.crt
|
||||
kubectl create secret generic kubernetes-dashboard-certs --from-file=$CERT_DIR -n kube-system
|
||||
cd ..
|
||||
|
||||
#Deploy the dashboard
|
||||
#wget https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
|
||||
wget https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml
|
||||
sed -i '176i\ type: LoadBalancer' kubernetes-dashboard.yaml
|
||||
kubectl apply -f kubernetes-dashboard.yaml
|
||||
|
||||
#Token based dashboard authentication
|
||||
kubectl create serviceaccount k8sadmin -n kube-system
|
||||
kubectl create clusterrolebinding k8sadmin --clusterrole=cluster-admin --serviceaccount=kube-system:k8sadmin
|
5
functions/kubeless/Gopkg.toml
Normal file
5
functions/kubeless/Gopkg.toml
Normal file
@ -0,0 +1,5 @@
|
||||
ignored = ["github.com/kubeless/kubeless/pkg/functions"]
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/sirupsen/logrus"
|
||||
branch = "master"
|
11
functions/kubeless/deploy_function.sh
Normal file
11
functions/kubeless/deploy_function.sh
Normal file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
#$1=runtime
|
||||
#$2=filename
|
||||
#$3=function name
|
||||
#$4=handler
|
||||
|
||||
kubeless function deploy $3 --runtime $1 --from-file $2 --handler $4
|
||||
kubeless trigger http create $3 --function-name $3 --path $3 --hostname $3.kubeless
|
||||
#kubeless autoscale create $3 --max 32 --metric "cpu" --min 3 --value "50"
|
||||
|
||||
#Test with curl --data '{"Another": "Echo"}' --header "Host: get-python.192.168.99.100.nip.io" --header "Content-Type:application/json" 192.168.99.100/echo
|
10
functions/kubeless/helloget.go
Normal file
10
functions/kubeless/helloget.go
Normal file
@ -0,0 +1,10 @@
|
||||
package kubeless
|
||||
|
||||
import (
|
||||
"github.com/kubeless/kubeless/pkg/functions"
|
||||
)
|
||||
|
||||
// Foo sample function
|
||||
func Foo(event functions.Event, context functions.Context) (string, error) {
|
||||
return "Hello world!", nil
|
||||
}
|
5
functions/kubeless/helloget.js
Normal file
5
functions/kubeless/helloget.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
foo: function (event, context) {
|
||||
return 'hello world!';
|
||||
}
|
||||
}
|
2
functions/kubeless/helloget.py
Normal file
2
functions/kubeless/helloget.py
Normal file
@ -0,0 +1,2 @@
|
||||
def foo(event, context):
|
||||
return "hello world"
|
27
functions/kubeless/isprime.go
Normal file
27
functions/kubeless/isprime.go
Normal file
@ -0,0 +1,27 @@
|
||||
package kubeless
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
|
||||
"github.com/kubeless/kubeless/pkg/functions"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func IsPrime(event functions.Event, context functions.Context) (string, error) {
|
||||
num, err := strconv.Atoi(event.Data)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Failed to parse %s as int! %v", event.Data, err)
|
||||
}
|
||||
logrus.Infof("Checking if %s is prime", event.Data)
|
||||
if num <= 1 {
|
||||
return fmt.Sprintf("%d is not prime", num), nil
|
||||
}
|
||||
for i := 2; i <= int(math.Floor(float64(num)/2)); i++ {
|
||||
if num%i == 0 {
|
||||
return fmt.Sprintf("%d is not prime", num), nil
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%d is prime", num), nil
|
||||
}
|
26
functions/kubeless/isprime.js
Normal file
26
functions/kubeless/isprime.js
Normal file
@ -0,0 +1,26 @@
|
||||
module.exports = {
|
||||
handler: (event, context) => {
|
||||
num=event.data;
|
||||
if (num == 1) return "Not Prime";
|
||||
num += 2;
|
||||
|
||||
var upper = Math.sqrt(num);
|
||||
var sieve = new Array(num)
|
||||
.join(',').split(',') // get values for map to work
|
||||
.map(function(){ return "Prime" });
|
||||
|
||||
for (var i = 2; i <= num; i++) {
|
||||
if (sieve[i]) {
|
||||
for (var j = i * i; j < num; j += i) {
|
||||
sieve[j] = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
if (sieve[num-2]) {
|
||||
return "Prime";
|
||||
};
|
||||
else {
|
||||
return "Not Prime";
|
||||
};
|
||||
},
|
||||
};
|
13
functions/kubeless/isprime.py
Normal file
13
functions/kubeless/isprime.py
Normal file
@ -0,0 +1,13 @@
|
||||
def isprime(event,context):
|
||||
n= event['data']
|
||||
if n == 2 or n == 3: return "Prime"
|
||||
if n < 2 or n%2 == 0: return "Not Prime"
|
||||
if n < 9: return "Prime"
|
||||
if n%3 == 0: return "Not Prime"
|
||||
r = int(n**0.5)
|
||||
f = 5
|
||||
while f <= r:
|
||||
if n%f == 0: return "Not Prime"
|
||||
if n%(f+2) == 0: return "Not Prime"
|
||||
f +=6
|
||||
return "Prime"
|
70
functions/kubeless/matrix.go
Normal file
70
functions/kubeless/matrix.go
Normal file
@ -0,0 +1,70 @@
|
||||
package kubeless
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/kubeless/kubeless/pkg/functions"
|
||||
)
|
||||
func main() {
|
||||
//Defining 2D matrices
|
||||
m1 := [3][3]int{
|
||||
[3]int{1, 1, 1},
|
||||
[3]int{1, 1, 1},
|
||||
[3]int{1, 1, 1},
|
||||
}
|
||||
m2 := [3][3]int{
|
||||
[3]int{1, 1, 1},
|
||||
[3]int{1, 1, 1},
|
||||
[3]int{1, 1, 1},
|
||||
}
|
||||
|
||||
//Declaring a matrix variable for holding the multiplication results
|
||||
var m3 [3][3]int
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
for j := 0; j < 3; j++ {
|
||||
m3[i][j] = 0
|
||||
for k := 0; k < 3; k++ {
|
||||
m3[i][j] = m3[i][j] + (m1[i][k] * m2[k][j])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
twoDimensionalMatrices := [3][3][3]int{m1, m2, m3}
|
||||
|
||||
matrixNames := []string{"MATRIX1", "MATRIX2", "MATRIX3 = MATRIX1*MATRIX2"}
|
||||
for index, m := range twoDimensionalMatrices {
|
||||
fmt.Println(matrixNames[index],":")
|
||||
showMatrixElements(m)
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
|
||||
//A function that displays matix elements
|
||||
func showMatrixElements(m [3][3]int) {
|
||||
for i := 0; i < 3; i++ {
|
||||
for j := 0; j < 3; j++ {
|
||||
fmt.Printf("%d\t", m[i][j])
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
MATRIX1 1 :
|
||||
1 1 1
|
||||
1 1 1
|
||||
1 1 1
|
||||
|
||||
MATRIX2 2 :
|
||||
1 1 1
|
||||
1 1 1
|
||||
1 1 1
|
||||
|
||||
MATRIX3 = MATRIX1*MATRIX2 3 :
|
||||
3 3 3
|
||||
3 3 3
|
||||
3 3 3
|
||||
|
||||
*/
|
Loading…
Reference in New Issue
Block a user