gcloud compute instances create my-unmanaged-instance --zone asia-east1-b
gcloud compute target-pools create my-pool --region asia-east1
gcloud compute forwarding-rules create my-rule --target-pool my-pool --region asia-east1
gcloud compute target-pools add-instances my-pool --instances my-unmanaged-instance --zone asia-east1-b
gcloud compute instance-templates create my-template
gcloud compute instance-groups managed create my-group --base-instance-name mgroup --size 1 --template my-template --target-pool my-pool --zone asia-east1-b
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
#!/bin/bash | |
# Environments | |
export PATH=/root/google-cloud-sdk/bin:$PATH | |
# Daily create snapshot for "backup_path" listed disks | |
# And remove snapshot 1 week old before | |
# Create snap date | |
export DT=`date +%Y%m%d` |
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
var http = require('http'); | |
var os = require('os'); | |
http.createServer(function(req, res){ | |
res.writeHead(200, {'Content-Type':'application/json'}); | |
res.end(JSON.stringify(os.cpus())); | |
}).listen(3000); |
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
/** | |
* Socket server | |
* file: web.js | |
*/ | |
var app = require('express')(); | |
var server = require('http').Server(app); | |
var io = require('socket.io')(server); | |
server.listen(80); |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
var os = require("os"); | |
//Create function to get CPU information | |
function cpuAverage() { | |
//Initialise sum of idle and time of cores and fetch CPU info | |
var totalIdle = 0, totalTick = 0; | |
var cpus = os.cpus(); | |
//Loop through CPU cores |
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
var bq = require('bigquery') | |
, fs = require('fs') | |
, prjId = 'mitac-cp300'; //you need to modify this | |
bq.init({ | |
json_file: '/Users/peihsinsu/.gcpkeys/mitac-cp300/mitac-cp300-e75b19c172ba.json' | |
}); | |
var sql = { | |
aaa: 'SELECT count(*) FROM [cp300.books2] LIMIT 1000' |
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
function runQuery() { | |
var projectId = 'sunny-573'; | |
var request = { | |
query: | |
"SELECT FORMAT_UTC_USEC(metadata.timestamp) as time, structPayload.rpitemp as pi_temp " + | |
"FROM [sunny-573:linkerlab.rpitemp_simon_project_LYDvUZWJJtOPxRERAAAC_20160902@-3600] " + | |
"WHERE metadata.labels.value = 'linker-log-gateway' ORDER BY structPayload.ctime desc LIMIT 3000" | |
}; |
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
systemctl stop docker | |
apt remove docker docker.io docker-ce docker-engine -y | |
apt autoremove docker docker.io docker-ce docker-engine -y | |
rm /etc/init/docker | |
rm /etc/init.d/docker | |
rm -rf /var/lib/docker | |
rm -rf /etc/docker | |
rm -rf /etc/default/docker | |
mv /var/lib/dpkg/info/docker-engine.* /tmp/ | |
apt update -y |
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
mkdir -p /etc/systemd/system/kubelet.service.d/ | |
cat > /etc/systemd/system/kubelet.service.d/20-node-eviction.conf <<EOF | |
Environment="KUBELET_EXTRA_ARGS=--eviction-hard=memory.available<500Mi --system-reserved=memory=1Gi" | |
EOF |
OlderNewer