K8 Quick Guide for MacOS and VirtualBox

Commands

 

# Commands What it does
1 sysctl -a | grep machdep.cpu.features | grep VMX Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS ru
2 brew update && brew install kubectl && brew cask install docker minikube virtualbox use brew to install kubectl, docker, minikube and virtualbox
3 docker –version

docker-compose –version

docker-machine –version

minikube version

kubectl version –client

verify the installation
4 minikube start start minikube

a local kubernetes cluster with one node

5 kubectl get nodes should show only one node
6 eval $(minikube docker-env) Use minikube’s built-in docker daemon:
7 docker ps
8 docker run -d -p 5000:5000 –restart=always –name registry registry:2 First setup a local registry, so Kubernetes can pull the image(s) from there.
9 docker build . –tag my-app build the Dockerfile below locally if you want to follow this guide to the letter. Store the Dockerfile locally, preferably in an empty directory and run:
10 docker tag my-app localhost:5000/my-app:0.1.0 You should now have an image named ‘my-app’ locally, check by using docker images (or your own image of course). You can then publish it to your local docker registry:
11 docker images
12 kubectl create -f my-app.yml deployment “my-app” created

service “my-app” created

13 kubectl get all show the pod and service
14 minikube service my-app –url The configuration exposes my-app outside of the cluster, you can get the address to access it by running
15 minikube dashboard start gui dashboard

URL is something like http://192.168.99.100:30000/

minikube ssh ssh to minikube
16 kubectl delete deploy my-app

kubectl delete service my-app

Delete deployment of my-app
17 minikube stop;

minikube delete;

rm -rf ~/.minikube .kube;

brew uninstall kubectl;

brew cask uninstall docker virtualbox minikube;

clean up everything

mysql-wordpress

 

# Commands What it does
1 kubectl version check version
2 kubectl create secret generic mysql-pass –from-literal=password=michelle create secret

use ‘michelle’ as password

3 kubectl get secrets verify secret
4 kubectl create -f mysql-deployment.yaml Deploy MySQL from the mysql-deployment.yaml file

The MYSQL_ROOT_PASSWORD environment variable sets the database password from the Secret

5 kubectl get pvc Verify that a PersistentVolume got dynamically provisioned
6 kubectl create -f wordpress-deployment.yaml Create a WordPress Service and Deployment from the wordpress-deployment.yaml file
7 kubectl get pvc kubectl get pvc
8 kubectl get services wordpress Verify that the Service is running by running the command
9 minikube service wordpress –url
10 kubectl delete secret mysql-pass

kubectl delete deployment -l app=wordpress

kubectl delete service -l app=wordpress

kubectl delete pvc -l app=wordpress

delete secret

delete all deployments and services

delete the PersistentVolumeClaims. The dynamically provisioned PersistentVolumes will be automatically deleted.

expose mysql to local
11 kubectl get pods retrieve the name of mysql pod
12 kubectl port-forward wordpress-mysql-86987f6b9-9zvbx 3306:3306 port forwarding

https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#port-forward/

13 connect to it use mysql workbench to connect via localhost:3306

References

  1. https://gist.github.com/kevin-smets/b91a34cea662d0c523968472a81788f7
  2. https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/#objectives
  3. Kubectl https://kubernetes.io/docs/tasks/tools/install-kubectl/#configure-kubectl
  4. Minikube https://kubernetes.io/docs/tutorials/stateless-application/hello-minikube/
Advertisements

site planning www.njfcs.org with AWS

potential functionalities

  • ads – revenue generator
  • monitor and alert solutions
  • address work – hard copy address book could be replaced by online inventory
  • site building blog (separate journal site)
  • dedicated email box
  • lunch order
  • homework submission
  • teacher’s page
  • department’s page
  • club’s page
  • yearly book
  • address book
  • content translator (google or bing API)
  • favicon
  • SEO
  • comment/feedback (facebook)
  • site stats
  • discussion board
  • video/photo
  • friendly/vanity URL for static pages
  • file management (ftp, webdav, http)
  • google analytics visit
  • scheduled post publishing
  • file sharing and version control (including yearly performance media files)
  • scheduled post expiration
  • email alias migration
  • mysql database backup
  • dedicated mailboxes for staff
  • secured password archive solution

business tool for school

  • accounting?
  • educational?
  • 總務

 

expense:

  • annual domain registration $12.95  ($6.99 godaddy.com as of 9/21/2012)
  • annual hosting service  $356.40 ($48 justhost.com as of 9/12/2012) – justhost coupon code 50OFF
  • Gwo-Ming out of pocket $?? (ec2 http://aws.amazon.com/pricing/ec2/)

cost forecast and comparison

 

 

current proposed
vendor cost vendor cost vendor
njfcs.org domain registration $12.95 eapps $6.99 godaddy.com
http://www.njfcs.org hosting $356.40 eapps $0 dreamhost non-profit org discount
registration site $200 Gwo-Ming $168 amazon ec2
mail service $120  1&1 $10 amazon ses
 phone number $8.95 $0 google voice

 

  • Separate domain name registration from hosting service give us the flexibility to move to another vendor at any time
  • I’ve subscribed amazon ec2 with njfcs1944@gmail.com with my own contact and credit card info – will have to be updated with school’s info; I’ve kept setup and config notes at http://derekchang.me/ec2-for-fcs/
  • Once you and staff confirm, I will go ahead to subscribe to justhost with a 2-year term ($2.48/month) so that we can proceed with implementing new services – will have to be updated with school’s info
  • Once 3 is done, webmaster team can start building new site but first step is to secure mysql backup and the file sharing services
  • eapps is dedicated host while justhost is shared virtual host and ec2 is virtual machine built upon xen framework – there are pros and cons for each them but new solutions will be more economic

 

EC2 pricing chart

http://aws.amazon.com/ec2/pricing/

1 year 3 year
medium windows micro =0.013*24*365+54 167.88 =0.013*24*365*3+82 423.64
light windows micro =0.018*24*365+23 180.68 =0.018*24*365*3+35 508.04
medium linux micro =0.007*24*365+54 115.32 =0.007*24*365*3+82 265.96
light linux micro =0.012*24*365+23 128.12 =0.012*24*365*3+35 350.36

 

 

currently on http://www.njfcs.org

 

Home 首頁 New URL
Hour/Location 上課時間/地點 http://njfcs.yuhsunn.com/contact2/
Calendar 行事曆 http://njfcs.yuhsunn.com/events/
About Us 關於維德
Announcements 公佈事項
Curriculum 教學事宜
PA Activities 家長會活動
Forms 各式表格
Policy 校務守則
Board Meetings 學校會議
Alumni 校友會
Registration 學生註冊 http://register.njfcs.org 
Account Update 資料更新
Help 需要幫助
In the Press 相關報導
Useful Links 相關網站
Contact Us 聯絡維德

opencart notes

Site implemented

http://www.hsinglu.idv.tw/

Steps to setup

  1. create subdomain
  2. opencart 1.5.2.1 http://www.opencart.com/
  3. google vqmod for opencart http://code.google.com/p/vqmod/
  4. 中文包 安裝 http://www.opencart.com/index.php?route=extension/extension/info&extension_id=2483
  5. vqmod add more (tweet, google+ facebook; no plurk)
  6. vqmod manufacturer top navigation http://www.opencart.com/index.php?route=extension/extension/info&extension_id=3633 (中文化needs to be addressed)
  7. vqmod view product in admin http://www.opencart.com/index.php?route=extension/extension/info&extension_id=5838
  8. vqmod negative price to contact us button http://www.opencart.com/index.php?route=extension/extension/info&extension_id=5295
  9. vqmod category filter http://www.opencart.com/index.php?route=extension/extension/info&extension_id=2663
  10. vqmod facebook comment http://www.opencart.com/index.php?route=extension/extension/info&extension_id=6026
  11. vqmod admin email format http://www.opencart.com/index.php?route=extension/extension/info&extension_id=4137
  12. city (區) selection module – http://www.opencart.com/index.php?route=extension/extension/info&extension_id=4372
  13. google map and corresponding module configuration
  14. US date format http://www.opencart.com/index.php?route=extension/extension/info&extension_id=4504
  15. import/export tool http://www.opencart.com/index.php?route=extension/extension/info&extension_id=17
  16. 測試
  17. 語系設定
  18. address format configuration http://opencart-hk.blogspot.com/2012/02/translatecountry.html
  19. 貨幣設定
  20. mail setting to notify admin upon registration and order placed
  21. test shopper registration and email notifcation
  22. 收費方式設定
  23. 運送方式設定
  24. 現金回饋/gift certificate and coupon.
  25. backup
  26. update current store listing
  27. enable google analytics
  28. opencart SEO URL
  29. site/product meta tag key words and description
  30. google sitemap generator http://www.opencart.com/index.php?route=extension/extension/info&extension_id=5985
  31. enable google sitemap
  32. submit sitemap to google
  33. facebook OC plugin http://www.opencart.com/index.php?route=extension/extension/info&extension_id=6015

Ajax quick edit (plugin) – Chinese encoding fix

http://www.opencart.com/index.php?route=extension/extension/info&extension_id=4202

in tableditajax.php
 <?php
header('Content-Type: text/html;charset=utf8');
include("../../config.php");
 $bd = mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD) or die("Could not connect database");
mysql_select_db(DB_DATABASE, $bd) or die("Could not select database");
 if($_POST['id'])
{
$id=mysql_escape_String($_POST['id']);
$name=mysql_escape_String($_POST['name']);
$model=mysql_escape_String($_POST['model']);
$price=mysql_escape_String($_POST['price']);
$quantity=mysql_escape_String($_POST['quantity']);
$sort_order=mysql_escape_String($_POST['sort_order']);
$sql = "update ". DB_PREFIX ."product_description set name='$name' where product_id='$id'";
mysql_query('SET NAMES "utf8"');
mysql_query($sql);
$sql = "update ". DB_PREFIX ."product set model='$model' , price='$price' , quantity='$quantity' , sort_order='$sort_order' where product_id='$id'";
mysql_query($sql);
 }
?>

Theme modification

powered by content – /catalog/language/zh-HK/common/footer.php

powered by alignment – /catalog/view/theme/default/stylesheet/stylesheet.css

 

#powered {
margin-top: 5px;
text-align: left;
clear: both;
}

Shipping Module & Customization

  1. admin\controller\shipping\flat.php
  2. admin\language\zh-HK\shipping\flat.php – change text
  3. admin\view\template\shipping\flat.tpl – change image path
  4. catalog\language\zh-HK\shipping\flat.php – change text
  5. catalog\model\shipping\flat.php
  6. admin\view\image\711.gif
  7. text on register page
  8. order of fields on register page
  9. 國家設置 – disable all other countries except Taiwan via SQL
use pnc_blmojhnenc;
select * from oc_country;
UPDATE oc_country SET status = 0 WHERE country_id <> 206;

 

SEO/FB

Opencart setup in 20 minutes

  1. install opencart (1.5.3.1)
  2. install following packages
    • google map
    • facebook comment
    • social
    • chat
    • keepalive admin
    • import/export
  3. setting up zh_TW language
  4. replace US$ to NT$ (TWD)
  5. edit store setting
    • store description
    • store name
    • owner
    • address
    • telephone number
    • fax number
    • email
    • location
    • default language
    • default currency
  6. disable all countries- UPDATE oc_country SET status = 0 WHERE country_id <> 206
  7. set zone setting – convert all english zone names to zh_TW
  8. remove  稅率類別from 商品稅類
  9. covert 區域群組

 

## remove 台中縣 台南縣 高雄縣

 

DELETE FROM oc_zone WHERE country_id =206 AND code IN (‘KH’,’TA’,’TG’);
## 中文名字
update oc_zone set name=’彰化縣’ where code=’CH’ and country_id=206;
update oc_zone set name=’嘉義縣’ where code=’CI’ and country_id=206;
update oc_zone set name=’新竹縣’ where code=’HS’ and country_id=206;
update oc_zone set name=’花蓮縣’ where code=’HL’ and country_id=206;
update oc_zone set name=’宜蘭縣’ where code=’IL’ and country_id=206;
update oc_zone set name=’金門縣’ where code=’KM’ and country_id=206;
update oc_zone set name=’連江縣’ where code=’LC’ and country_id=206;
update oc_zone set name=’苗栗縣’ where code=’ML’ and country_id=206;
update oc_zone set name=’南投縣’ where code=’NT’ and country_id=206;
update oc_zone set name=’澎湖縣’ where code=’PH’ and country_id=206;
update oc_zone set name=’屏東縣’ where code=’PT’ and country_id=206;
update oc_zone set name=’新北市’ where code=’TC’ and country_id=206;
update oc_zone set name=’台東縣’ where code=’TT’ and country_id=206;
update oc_zone set name=’桃園縣’ where code=’TY’ and country_id=206;
update oc_zone set name=’雲林縣’ where code=’CC’ and country_id=206;
update oc_zone set name=’嘉義市’ where code=’YL’ and country_id=206;
update oc_zone set name=’基隆市’ where code=’CL’ and country_id=206;
update oc_zone set name=’新竹市’ where code=’HC’ and country_id=206;
update oc_zone set name=’台中市’ where code=’TH’ and country_id=206;
update oc_zone set name=’台南市’ where code=’TN’ and country_id=206;
update oc_zone set name=’高雄市’ where code=’KC’ and country_id=206;
update oc_zone set name=’台北市’ where code=’TP’ and country_id=206;

sendy customization

http://sendy.co/get-started

  • change database to utf8_general_ci
  • change following fields to utf8_general_ci – name, plain_text, html_text
  • change following campaigns table and “title” field (aka subject)  to utf8_general_ci (chinese character encoding in the subject)

sendy

DDL-DML-DCL-TCL

DDL

Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples:

 

  • CREATE – to create objects in the database
  • ALTER – alters the structure of the database
  • DROP – delete objects from the database
  • TRUNCATE – remove all records from a table, including all spaces allocated for the records are removed
  • COMMENT – add comments to the data dictionary
  • RENAME – rename an object

 

DML

Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples:

 

  • SELECT – retrieve data from the a database
  • INSERT – insert data into a table
  • UPDATE – updates existing data within a table
  • DELETE – deletes all records from a table, the space for the records remain
  • MERGE – UPSERT operation (insert or update)
  • CALL – call a PL/SQL or Java subprogram
  • EXPLAIN PLAN – explain access path to data
  • LOCK TABLE – control concurrency

 

DCL

Data Control Language (DCL) statements. Some examples:

 

  • GRANT – gives user’s access privileges to database
  • REVOKE – withdraw access privileges given with the GRANT command

 

TCL

Transaction Control (TCL) statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.

 

  • COMMIT – save work done
  • SAVEPOINT – identify a point in a transaction to which you can later roll back
  • ROLLBACK – restore database to original since the last COMMIT
  • SET TRANSACTION – Change transaction options like isolation level and what rollback segment to use

Blog at WordPress.com.

Up ↑