12.27.2017
12.14.2017
Getting Started with Kubernetes
1. Install Minikube $ brew update $ brew install kubectl $ brew cask install minikube 2. Install xhyve $ brew install docker-machine-driver-xhyve 3. Set superuser privileges for xhyve (this appears during installation) $ sudo chown root:wheel /usr/local/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve $ sudo chmod u+s /usr/local/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve 4. Start minikube $ minikube start --vm-driver=xhyve 5. Test $ kubectl config current-context minikube 6. Get cluster nodes info $ kubectl get nodes NAME STATUS ROLES AGE VERSION minikube Ready22m v1.8.0 7. Stop cluster $ minikube stop Stopping local Kubernetes cluster... Machine stopped. 8. Delete minikube $ minikube delete Deleting local Kubernetes cluster... Machine deleted. 9. Show available kubernetes versions $ minikube get-k8s-versions The following Kubernetes versions are available when using the localkube bootstrapper: - v1.8.0 - v1.7.5 - v1.7.4 ... 10. Get v1.8.0 $ minikube start --vm-driver=xhyve --kubernetes-version="v1.8.0" 11. Start dashboard $ minikube dashboard
10.18.2017
Get Custom Settings in Django
1. Insert additional settings this way...
In settings.py, or settings/development.py, can insert whatever data structure...
RESOURCE_CREDENTIALS = {
'client': {
'USERNAME': 'root',
'PASSWORD': 'abc123',
},
'server': {
'USERNAME': 'root',
'PASSWORD': 'ABC123!',
}
}
2. Then from the app access it this way...
e.g., in views.py...
from django.conf import settings
RESOURCE_CREDENTIALS = getattr(settings, 'RESOURCE_CREDENTIALS')
USERNAME = RESOURCE_CREDENTIALS["client"]["USERNAME"]
PASSWORD = RESOURCE_CREDENTIALS["client"]["PASSWORD"]
10.03.2017
How to Integrate Clarity UI on your Angular App
I heart Clarity UI.Install
$ yarn add clarity-icons $ yarn add @webcomponents/custom-elements@1.0.0 $ yarn add clarity-ui $ yarn add clarity-angularUse clarity on Angular
$ vi .angular-cli.json "styles": [ ... "../node_modules/clarity-icons/clarity-icons.min.css", "../node_modules/clarity-ui/clarity-ui.min.css" ], "scripts": [ ... "../node_modules/@webcomponents/custom-elements/custom-elements.min.js", "../node_modules/clarity-icons/clarity-icons.min.js" ], $ vi app.module.ts import { ClarityModule } from "clarity-angular"; imports: [ ... ClarityModule.forRoot(), ... ],
9.21.2017
Angular Development Production Settings
This came from this post Angular apps created using angular-cli will have src/environments directory. 1. Add another file in there called environment.staging.ts with the following entry... export const environment = { production: false, envName: 'staging' }; 2. Modify .angular.cli.json "environments": { "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts", "staging": "environments/environment.staging.ts" } 3. Now when creating a build or serving the app.. $ ng build -prod $ ng build -staging $ ng serve -prod $ ng serve -staging 4. To use... import { environment } from './environment'; export class MyappAppComponent { title = 'myapp works!'; environmentName = environment.envName; }
9.13.2017
VS Code Cheat Sheet
Full list of shortcuts
1. Detach file to another window ⌘K, O 2. Format file ⇧ + Opt + F 3. Preview side-by-side ⌘K, V 4. Screen shot ⇧⌘3 - whole screen ⇧⌘4 - selection
9.08.2017
Celery Tasks Parallel and Chained Execution Workflow
In celery, it is very easy to chain and parallelize execution of tasks, e.g. to satisfy this example workflow...
_____
|task1| 1. exec task1
/ \
__/__ __\__
|task2| |task3| 2. parallel task1 & task2
\ /
\ _____/
|task4| 3. exec task4 when both task1 & task2 are done
from celery import chain, group, chord
from orchestrator.tasks.host_tasks import acquire_hosts, prepare_hosts, return_hosts
from orchestrator.tasks.job_tasks import start_job, stop_job
from orchestrator.tasks.vcenter_tasks import acquire_vcenter, return_vcenter
def start_performance_run_workflow(job_id):
print('Starting performance run workflows for job %s' % job_id)
# The effect of this chain, is that only the first one is routed
# to the "regular.priority" queue
# subsequent tasks are routed to "celery" default queue
workflow = chain(
acquire_hosts.si(job_id),
chord(
(prepare_hosts.si(job_id), acquire_vcenter.si(job_id)),
start_job.si(job_id)
)
).apply_async(queue="regular.priority")
Subscribe to:
Posts (Atom)