Last active
November 29, 2016 00:06
-
-
Save chianingwang/ebfe8eb7fb1057acf06f50ba187cd62b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#swift-object-notify is a execution under /opt/ss/lib/python2.7/site-packages/swift-metadata-sync.egg-link | |
#container-crawler is a middleware need to be installed and run under | |
Download to local for modification | |
Johnnys-MacBook-Pro:git jwang$ git clone https://github.com/swiftstack/swift-object-notify.git | |
Cloning into 'swift-object-notify'... | |
remote: Counting objects: 16, done. | |
remote: Compressing objects: 100% (10/10), done. | |
remote: Total 16 (delta 3), reused 13 (delta 3), pack-reused 0 | |
Unpacking objects: 100% (16/16), done. | |
Checking connectivity... done. | |
Johnnys-MacBook-Pro:git jwang$ cd swift-object-notify/ | |
Johnnys-MacBook-Pro:swift-object-notify jwang$ ls | |
LICENSE MANIFEST.in requirements.txt setup.py swift_object_notify | |
Johnnys-MacBook-Pro:swift-object-notify jwang$ git pull | |
Already up-to-date. | |
Login PACO server , install git and download code from git again | |
[vagrant@ss-12 ~]$ sudo yum install git -y | |
. . . | |
Complete! | |
[vagrant@ss-12 ~]$ git clone https://github.com/swiftstack/swift-object-notify.git | |
Cloning into 'swift-object-notify'... | |
Username for 'https://github.com': chianingwang | |
Password for 'https://[email protected]': | |
remote: Counting objects: 16, done. | |
remote: Compressing objects: 100% (10/10), done. | |
remote: Total 16 (delta 3), reused 13 (delta 3), pack-reused 0 | |
Unpacking objects: 100% (16/16), done. | |
===Before fix the requiremet.txt=== | |
We manual install container-crawler | |
[vagrant@ss-12 ~]$ git https://github.com/swiftstack/container-crawler.git | |
git: 'https://github.com/swiftstack/container-crawler.git' is not a git command. See 'git --help'. | |
[vagrant@ss-12 ~]$ git clone https://github.com/swiftstack/container-crawler.git | |
Cloning into 'container-crawler'... | |
remote: Counting objects: 48, done. | |
remote: Total 48 (delta 0), reused 0 (delta 0), pack-reused 48 | |
Unpacking objects: 100% (48/48), done. | |
[vagrant@ss-12 ~]$ cd container-crawler/ | |
[vagrant@ss-12 container-crawler]$ ls | |
container_crawler LICENSE MANIFEST.in README.md requirements-test.txt requirements.txt setup.py test | |
[vagrant@ss-12 container-crawler]$ sudo /opt/ss/bin/pip install -e ./ | |
You are using pip version 6.0.8, however version 9.0.1 is available. | |
You should consider upgrading via the 'pip install --upgrade pip' command. | |
Obtaining file:///home/vagrant/container-crawler | |
Installing collected packages: container-crawler | |
Running setup.py develop for container-crawler | |
Creating /opt/ss/lib/python2.7/site-packages/container-crawler.egg-link (link to .) | |
Adding container-crawler 0.0.1 to easy-install.pth file | |
Installed /home/vagrant/container-crawler | |
Successfully installed container-crawler-0.0.1 | |
[vagrant@ss-12 swift-object-notify]$ sudo /opt/ss/bin/pip install -e ./ | |
You are using pip version 6.0.8, however version 9.0.1 is available. | |
You should consider upgrading via the 'pip install --upgrade pip' command. | |
Obtaining file:///home/vagrant/swift-object-notify | |
Installing collected packages: swift-object-notify | |
Running setup.py develop for swift-object-notify | |
Creating /opt/ss/lib/python2.7/site-packages/swift-object-notify.egg-link (link to .) | |
Adding swift-object-notify 0.0.1 to easy-install.pth file | |
Installing swift-object-notify script to /opt/ss/bin | |
Installed /home/vagrant/swift-object-notify | |
Successfully installed swift-object-notify | |
Then you should be able to find the executable binary here : /opt/ss/bin/swift-object-notify | |
[vagrant@ss-12 swift-object-notify]$ /opt/ss/bin/swift-object-notify | |
usage: swift-object-notify [-h] --config conf [--once] [--log-level level] | |
[--console] | |
swift-object-notify: error: argument --config is required | |
===configuration=== | |
[vagrant@ss-12 ~]$ cd swift-object-notify/ | |
[vagrant@ss-12 swift-object-notify]$ ls | |
LICENSE MANIFEST.in requirements.txt setup.py swift_object_notify | |
[vagrant@ss-12 swift-object-notify]$ cd swift_object_notify/ | |
[vagrant@ss-12 swift_object_notify]$ ls | |
__init__.py __main__.py swift_notify.py | |
[vagrant@ss-12 swift_object_notify]$ vi swift_notify.py | |
. . . | |
def handle(self, row): | |
# TODO: do something | |
print row | |
[vagrant@ss-12 swift_object_notify]$ vi swift_notify.py test.conf | |
{"devices":"/srv/node", "status_dir":"/tmp/notify", "items_chunk":100, "containers": | |
[{"account":"AUTH_ss","container":"test-container"}]} | |
[vagrant@ss-12 swift_object_notify]$ mkdir /tmp/notify | |
Make sure you do have container call ""test-container" | |
Johnnys-MacBook-Pro:~ jwang$ swift -A http://172.28.128.4/auth/v1.0 -U ss -K ss stat -v test-container | |
URL: http://172.28.128.4/v1/AUTH_ss/test-container | |
Auth Token: AUTH_tkcbe828f9411f4a0c8843c985d1cac1e4 | |
Account: AUTH_ss | |
Container: test-container | |
Objects: 12 | |
Bytes: 433164884 | |
Read ACL: .r:*,.rlistings | |
Write ACL: | |
Sync To: | |
Sync Key: | |
Accept-Ranges: bytes | |
X-Trans-Id: tx3f249712071f40df9823b-00583c86ff | |
X-Storage-Policy: Standard-Replica | |
Last-Modified: Mon, 21 Nov 2016 08:25:01 GMT | |
X-Timestamp: 1479690213.47529 | |
Content-Type: text/plain; charset=utf-8 | |
Johnnys-MacBook-Pro:~ jwang$ swift -A http://172.28.128.4/auth/v1.0 -U ss -K ss list | |
.swiftstack-web-console-metadata | |
test-container | |
Johnnys-MacBook-Pro:~ jwang$ swift -A http://172.28.128.4/auth/v1.0 -U ss -K ss list test-container | |
bbb_sunflower_1080p_60fps_normal.mp4 | |
out.mp4 | |
output_file_1.mp4 | |
output_file_10.mp4 | |
output_file_11.mp4 | |
output_file_3.mp4 | |
output_file_4.mp4 | |
output_file_5.mp4 | |
output_file_6.mp4 | |
output_file_7.mp4 | |
output_file_8.mp4 | |
output_file_9.mp4 | |
===run=== | |
# this will run only once | |
$ sudo /opt/ss/bin/swift-object-notify --config test.conf --console --log-level debug --once | |
#e.g: | |
[vagrant@ss-12 swift-object-notify]$ sudo /opt/ss/bin/swift-object-notify --config test.conf --console --log-level debug --once | |
[2016-11-28 19:38:58,442] swift-object-notify [INFO]: Starting Swift object notifcation daemon | |
[2016-11-28 19:38:58,463] swift-object-notify [DEBUG]: Created the Container Crawler instance | |
{'name': 'output_file_2.mp4', 'deleted': 1, 'created_at': '1479713450.80710', 'storage_policy_index': 0, 'etag': 'noetag', 'content_type': 'application/deleted', 'ROWID': 96, 'size': 0} | |
{'name': 'cut.mp4', 'deleted': 1, 'created_at': '1479713468.60060', 'storage_policy_index': 0, 'etag': 'noetag', 'content_type': 'application/deleted', 'ROWID': 105, 'size': 0} | |
{'name': 'output_file_1.mp4', 'deleted': 0, 'created_at': '1479716358.61602', 'storage_policy_index': 0, 'etag': '2b1b16a843e478587471a335d445caec', 'content_type': 'video/mp4', 'ROWID': 117, 'size': 405238} | |
{'name': 'output_file_6.mp4', 'deleted': 0, 'created_at': '1479716432.25032', 'storage_policy_index': 0, 'etag': '71911537d6da6088ab74f90da2fbe1b9', 'content_type': 'video/mp4', 'ROWID': 120, 'size': 5862569} | |
{'name': 'output_file_5.mp4', 'deleted': 0, 'created_at': '1479716510.02714', 'storage_policy_index': 0, 'etag': '80b638461618fc9f5327efd2bf27c7f6', 'content_type': 'video/mp4', 'ROWID': 123, 'size': 5133786} | |
{'name': 'bbb_sunflower_1080p_60fps_normal.mp4', 'deleted': 0, 'created_at': '1479690373.31939', 'storage_policy_index': 0, 'etag': '7a7bc8ae38ccbd700e07977a9deb8cb7', 'content_type': 'video/mp4', 'ROWID': 1, 'size': 355856562} | |
{'name': 'out.mp4', 'deleted': 0, 'created_at': '1479712972.95893', 'storage_policy_index': 0, 'etag': 'fdc58c7ef49a152343a09ed3f2098b92', 'content_type': 'video/mp4', 'ROWID': 92, 'size': 10767846} | |
{'name': 'cut4.mp4', 'deleted': 1, 'created_at': '1479713465.22096', 'storage_policy_index': 0, 'etag': 'noetag', 'content_type': 'application/deleted', 'ROWID': 104, 'size': 0} | |
{'name': 'output_file_11.mp4', 'deleted': 0, 'created_at': '1479716356.80029', 'storage_policy_index': 0, 'etag': 'efee928d91370b95d66a12f9046c737c', 'content_type': 'video/mp4', 'ROWID': 116, 'size': 3677805} | |
{'name': 'output_file_4.mp4', 'deleted': 0, 'created_at': '1479716429.61673', 'storage_policy_index': 0, 'etag': '6e0db19a7144b383f14ec0f05a94628f', 'content_type': 'video/mp4', 'ROWID': 118, 'size': 2888687} | |
{'name': 'output_file_7.mp4', 'deleted': 0, 'created_at': '1479716430.79602', 'storage_policy_index': 0, 'etag': 'ab77d9a278c231da2d3912b5ad7e2239', 'content_type': 'video/mp4', 'ROWID': 119, 'size': 3365741} | |
{'name': 'output_file_10.mp4', 'deleted': 0, 'created_at': '1479716481.53993', 'storage_policy_index': 0, 'etag': '13b844599eef66497aa28775b37aea58', 'content_type': 'video/mp4', 'ROWID': 121, 'size': 10409223} | |
{'name': 'output_file_9.mp4', 'deleted': 0, 'created_at': '1479716485.96882', 'storage_policy_index': 0, 'etag': '5054137beee93fff5a3be2dd561f773c', 'content_type': 'video/mp4', 'ROWID': 122, 'size': 2882009} | |
{'name': 'output_file_3.mp4', 'deleted': 0, 'created_at': '1479716678.51817', 'storage_policy_index': 0, 'etag': 'd5dd041342537b4cc16335d62ff7c370', 'content_type': 'video/mp4', 'ROWID': 124, 'size': 10964581} | |
{'name': 'output_file_8.mp4', 'deleted': 0, 'created_at': '1479716700.71262', 'storage_policy_index': 0, 'etag': '741fa6150a785e9a46275541f610142a', 'content_type': 'video/mp4', 'ROWID': 125, 'size': 20950837} | |
# this will run every 5 seconds | |
$ sudo /opt/ss/bin/swift-object-notify --config test.conf --console --log-level info | |
The row dictionary print out like this | |
[2016-11-28 19:45:02,343] swift-object-notify [INFO]: Starting Swift object notifcation daemon | |
{'name': 'out.mp4', 'deleted': 1, 'created_at': '1480362350.52007', 'storage_policy_index': 0, 'etag': 'noetag', 'content_type': 'application/deleted', 'ROWID': 126, 'size': 0} | |
{'name': 'Vagrantfile', 'deleted': 0, 'created_at': '1480362585.84997', 'storage_policy_index': 0, 'etag': '85167f674ce062058c3edba76b7007bf', 'content_type': 'application/octet-stream', 'ROWID': 127, 'size': 2004} | |
{'name': 'Vagrantfile', 'deleted': 0, 'created_at': '1480362671.83985', 'storage_policy_index': 0, 'etag': 'f2dce29e6d55364f4f0e59b7f6a67712', 'content_type': 'application/octet-stream', 'ROWID': 128, 'size': 1996} | |
{'name': 'test.mp3', 'deleted': 0, 'created_at': '1480362747.63219', 'storage_policy_index': 0, 'etag': 'f6c00f369359e99cc55ff254ad00e6c0', 'content_type': 'audio/mpeg', 'ROWID': 129, 'size': 21} | |
{'name': 'Vagrantfile', 'deleted': 1, 'created_at': '1480362811.91319', 'storage_policy_index': 0, 'etag': 'noetag', 'content_type': 'application/deleted', 'ROWID': 130, 'size': 0} | |
Analysis row ( json ) format | |
{ | |
'name': 'test.mp3', //this is file name | |
'deleted': 0, //this is deleted flag, if it is create then 0 else it is 1 | |
'created_at': '1480362747.63219', //timestamp | |
'storage_policy_index': 0, //storage policy, default is 0 | |
'etag': 'f6c00f369359e99cc55ff254ad00e6c0', //etag ( md5 fingerprint for file content ) | |
'content_type': 'audio/mpeg', //content type, file type, we target on "audio/mpeg" | |
'ROWID': 129, //row id | |
'size': 21 //file size | |
} | |
===udpate swift_notify.py and re-deployment=== | |
[vagrant@ss-12 swift-object-notify]$ sudo /opt/ss/bin/pip install -e ./ | |
You are using pip version 6.0.8, however version 9.0.1 is available. | |
You should consider upgrading via the 'pip install --upgrade pip' command. | |
Obtaining file:///home/vagrant/swift-object-notify | |
Installing collected packages: swift-object-notify | |
Running setup.py develop for swift-object-notify | |
Creating /opt/ss/lib/python2.7/site-packages/swift-object-notify.egg-link (link to .) | |
swift-object-notify 0.0.1 is already the active version in easy-install.pth | |
Installing swift-object-notify script to /opt/ss/bin | |
Installed /home/vagrant/swift-object-notify | |
[vagrant@ss-12 swift-object-notify]$ sudo /opt/ss/bin/swift-object-notify --config test.conf --console --log-level info | |
[2016-11-28 22:45:30,905] swift-object-notify [INFO]: Starting Swift object notifcation daemon | |
{'name': 'test.mp3', 'deleted': 1, 'created_at': '1480373234.05383', 'storage_policy_index': 0, 'etag': 'noetag', 'content_type': 'application/deleted', 'ROWID': 131, 'size': 0} | |
======== | |
name test.mp3 | |
deleted 1 | |
created_at 1480373234.05383 | |
storage_policy_index 0 | |
etag noetag | |
content_type application/deleted | |
ROWID 131 | |
size 0 | |
{'name': 'test.mp3', 'deleted': 0, 'created_at': '1480373510.71038', 'storage_policy_index': 0, 'etag': 'f6c00f369359e99cc55ff254ad00e6c0', 'content_type': 'audio/mpeg', 'ROWID': 132, 'size': 21} | |
======== | |
name test.mp3 | |
deleted 0 | |
created_at 1480373510.71038 | |
storage_policy_index 0 | |
etag f6c00f369359e99cc55ff254ad00e6c0 | |
content_type audio/mpeg | |
ROWID 132 | |
size 21 | |
The authenticity of host '172.28.128.5 (172.28.128.5)' can't be established. | |
ECDSA key fingerprint is 03:7d:1e:ff:b2:fb:98:ef:71:90:99:88:ac:b5:f4:e0. | |
Are you sure you want to continue connecting (yes/no)? yes | |
Warning: Permanently added '172.28.128.5' (ECDSA) to the list of known hosts. | |
[email protected]'s password: | |
job "demo1" created | |
0 | |
{'name': 'test.mp3', 'deleted': 1, 'created_at': '1480373680.13400', 'storage_policy_index': 0, 'etag': 'noetag', 'content_type': 'application/deleted', 'ROWID': 133, 'size': 0} | |
======== | |
name test.mp3 | |
deleted 1 | |
created_at 1480373680.13400 | |
storage_policy_index 0 | |
etag noetag | |
content_type application/deleted | |
ROWID 133 | |
size 0 | |
{'name': 'test.mp3', 'deleted': 0, 'created_at': '1480373699.32293', 'storage_policy_index': 0, 'etag': 'f6c00f369359e99cc55ff254ad00e6c0', 'content_type': 'audio/mpeg', 'ROWID': 134, 'size': 21} | |
======== | |
name test.mp3 | |
deleted 0 | |
created_at 1480373699.32293 | |
storage_policy_index 0 | |
etag f6c00f369359e99cc55ff254ad00e6c0 | |
content_type audio/mpeg | |
ROWID 134 | |
size 21 | |
job "demo1" created | |
0 | |
{'name': 'test.mp3', 'deleted': 1, 'created_at': '1480373742.94275', 'storage_policy_index': 0, 'etag': 'noetag', 'content_type': 'application/deleted', 'ROWID': 135, 'size': 0} | |
======== | |
name test.mp3 | |
deleted 1 | |
created_at 1480373742.94275 | |
storage_policy_index 0 | |
etag noetag | |
content_type application/deleted | |
ROWID 135 | |
size 0 | |
{'name': 'test.mp3', 'deleted': 0, 'created_at': '1480373788.33771', 'storage_policy_index': 0, 'etag': 'f6c00f369359e99cc55ff254ad00e6c0', 'content_type': 'audio/mpeg', 'ROWID': 136, 'size': 21} | |
======== | |
name test.mp3 | |
deleted 0 | |
created_at 1480373788.33771 | |
storage_policy_index 0 | |
etag f6c00f369359e99cc55ff254ad00e6c0 | |
content_type audio/mpeg | |
ROWID 136 | |
size 21 | |
job "demo1" created | |
0 | |
===PS=== | |
If you setup kubernete server on your proxy node, please disable ssnoded for restart the firewalld and disable the firewalld before we sort out the firewall rule for docker and kubernetes | |
If you setup kubernete server on another VirtualBox VM, please add 3 NICs for both Proxy nodes and Kubernete server. | |
1. NAT | |
2. Host-Only Adapter -> vboxnet0 | |
3. Internal Network -> intnet | |
Add ssh-key for proxy node root since we trigger daemon via $ sudo /opt/ss/bin/swift-object-notify --config test.conf --console --log-level info | |
Generate ssh-key | |
$ ssh-keygen -t rsa | |
Copy key to from Proxy server ( root ) to kubernetes server ( e.g: 172.28.128.5 ) | |
$ ssh-copy-id [email protected] | |
Finally, please make sure weave-net-*** (2) and kuber-dns-*** (3) are all up, otherwise the network won't work. | |
user@ubuntu:~/Desktop/K8S$ kubectl get pods --all-namespaces | |
NAMESPACE NAME READY STATUS RESTARTS AGE | |
kube-system etcd-ubuntu 1/1 Running 10 34d | |
kube-system kube-apiserver-ubuntu 1/1 Running 12 34d | |
kube-system kube-controller-manager-ubuntu 1/1 Running 10 34d | |
kube-system kube-discovery-982812725-55zmi 1/1 Running 5 12d | |
kube-system kube-dns-2247936740-swjx1 3/3 Running 32 34d | |
kube-system kube-proxy-amd64-s4hor 1/1 Running 10 34d | |
kube-system kube-scheduler-ubuntu 1/1 Running 10 34d | |
kube-system weave-net-2ifri 2/2 Running 168 34d | |
info: 2 completed object(s) was(were) not shown in pods list. Pass --show-all to see all object | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment