From 638495df99d2261a843a3fcf39094253af02e90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Thu, 12 Sep 2019 10:48:23 +0200 Subject: [PATCH] implement syntax highlighting for the whole site --- .../blog/enable-global-policies-apicast.md | 10 +-- content/blog/is-my-ntp-daemon-working.md | 4 +- ...nage-the-qos-of-your-openshift-workload.md | 6 +- .../use-qlkube-to-query-the-kubernetes-api.md | 64 +++++++++---------- themes/cocoa | 2 +- 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/content/blog/enable-global-policies-apicast.md b/content/blog/enable-global-policies-apicast.md index 21020a8..af7a110 100644 --- a/content/blog/enable-global-policies-apicast.md +++ b/content/blog/enable-global-policies-apicast.md @@ -19,7 +19,7 @@ Start from those default *Environment Files* and add a `policy_chain` field with The default *Global Policy Chain* can be found in the [`gateway/src/apicast/policy_chain.lua`](https://github.com/3scale/APIcast/blob/b8f7f067dd47936f93bc9bd3e6de224c304d58ea/gateway/src/apicast/policy_chain.lua#L67-L72) file. **production.lua:** -{{< highlight lua >}} +{{< highlight lua "hl_lines=8-14" >}} return { master_process = 'on', lua_code_cache = 'on', @@ -38,7 +38,7 @@ return { {{< / highlight >}} **staging.lua:** -```lua +{{< highlight lua "hl_lines=7-13" >}} return { master_process = 'on', lua_code_cache = 'on', @@ -53,12 +53,12 @@ return { 'apicast.policy.nginx_metrics' }), } -``` +{{< / highlight >}} Then, create a ConfigMap from those two files and mount it in `/opt/app-root/src/config`: -```sh +{{< highlight sh >}} oc create configmap apicast-cors --from-file=production.lua --from-file=staging.lua oc set volume dc/apicast-production --add --name=apicast-cors -t configmap --configmap-name=apicast-cors -m /opt/app-root/src/config oc set volume dc/apicast-staging --add --name=apicast-cors -t configmap --configmap-name=apicast-cors -m /opt/app-root/src/config -``` +{{< / highlight >}} diff --git a/content/blog/is-my-ntp-daemon-working.md b/content/blog/is-my-ntp-daemon-working.md index fcc0447..9651bb0 100644 --- a/content/blog/is-my-ntp-daemon-working.md +++ b/content/blog/is-my-ntp-daemon-working.md @@ -19,7 +19,7 @@ time. First, make sure your NTP daemon is started: -```sh +```raw $ sudo systemctl status ntpd ● ntpd.service - Network Time Service Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled) @@ -96,7 +96,7 @@ sudo systemctl stop ntpd Then, run the ntpdate command: -```sh +```raw $ sudo ntpdate -q 0.rhel.pool.ntp.org server 91.121.88.161, stratum 2, offset -0.000393, delay 0.02974 server 129.250.35.251, stratum 2, offset 0.004071, delay 0.02733 diff --git a/content/blog/use-ansible-to-manage-the-qos-of-your-openshift-workload.md b/content/blog/use-ansible-to-manage-the-qos-of-your-openshift-workload.md index 61a0a7c..50f2486 100644 --- a/content/blog/use-ansible-to-manage-the-qos-of-your-openshift-workload.md +++ b/content/blog/use-ansible-to-manage-the-qos-of-your-openshift-workload.md @@ -49,7 +49,7 @@ had a `requests` or `limits` field in it. This first task has been accomplished very easily with a first playbook: -```yaml +```raw - name: List all DeploymentConfig having a request or limit set hosts: localhost gather_facts: no @@ -162,7 +162,7 @@ in order to bring back those objects to the Best Effort QoS class. Since I do not want all Pods to have the Best Effort QoS class, I added a blacklist of critical namespaces that should not be touched. -```raw +{{< highlight raw "hl_lines=5-10 23" >}} - name: Change the QoS class of commodity projects hosts: localhost gather_facts: no @@ -186,7 +186,7 @@ blacklist of critical namespaces that should not be touched. loop_control: loop_var: obj when: obj.namespace not in namespace_blacklist -``` +{{< / highlight >}} You can find the complete playbook [here](change-qos.yaml). Of course, it is very rough and would need to more work to be used on a daily basis but for a diff --git a/content/blog/use-qlkube-to-query-the-kubernetes-api.md b/content/blog/use-qlkube-to-query-the-kubernetes-api.md index f34a8d7..a5cd4c6 100644 --- a/content/blog/use-qlkube-to-query-the-kubernetes-api.md +++ b/content/blog/use-qlkube-to-query-the-kubernetes-api.md @@ -14,34 +14,34 @@ It is very useful for mobile application and web development: by reducing the nu To install QLKube in OpenShift, use the NodeJS Source-to-Image builder: -```sh +{{< highlight sh >}} oc new-project qlkube --display-name=QLKube oc new-app nodejs~https://github.com/qlkube/qlkube.git --name=qlkube -``` +{{< / highlight >}} Disable TLS certificate validation to accommodate your self-signed certificates: -```sh +{{< highlight sh >}} oc set env dc/qlkube NODE_TLS_REJECT_UNAUTHORIZED=0 -``` +{{< / highlight >}} And enable the NodeJS development mode to enable the GraphQL explorer (disabled in production mode): -```sh +{{< highlight sh >}} oc set env dc/qlkube NODE_ENV=development -``` +{{< / highlight >}} Give the GLKube's Service Account the right to query the Kubernetes API for its own namespace: -```sh +{{< highlight sh >}} oc adm policy add-role-to-user view -z default -``` +{{< / highlight >}} Once deployed, open the QLKube URL in your web browser: -```sh +{{< highlight sh >}} open $(oc get route qlkube -o go-template --template="http://{{.spec.host}}") -``` +{{< / highlight >}} You can try the following queries in the GraphQL explorer. @@ -51,7 +51,7 @@ Unless you gave the `cluster-admin` right to the QLKube Service Account, you wil **Query:** -```graphql +{{< highlight graphql >}} query getAllPodsInCurrentNamespace { all(namespace: "qlkube") { pods { @@ -67,11 +67,11 @@ query getAllPodsInCurrentNamespace { } } } -``` +{{< / highlight >}} **Response:** -```json +{{< highlight json >}} { "data": { "all": { @@ -100,7 +100,7 @@ query getAllPodsInCurrentNamespace { } } } -``` +{{< / highlight >}} ## Get a service by name @@ -108,7 +108,7 @@ To get an object by name, you can use the `fieldSelector` parameter (in this exa **Query:** -```graphql +{{< highlight graphql >}} query getServiceByNameAndNamespace { all(namespace: "qlkube", fieldSelector: "metadata.name=qlkube") { services { @@ -124,11 +124,11 @@ query getServiceByNameAndNamespace { } } } -``` +{{< / highlight >}} **Response:** -```json +{{< highlight json >}} { "data": { "all": { @@ -148,14 +148,14 @@ query getServiceByNameAndNamespace { } } } -``` +{{< / highlight >}} ## Type introspection Playing with the built-in types of GLKube is nice but you might soon be limited. To discover all the available types, run this query: -```graphql +{{< highlight graphql >}} { __schema { types { @@ -163,11 +163,11 @@ To discover all the available types, run this query: } } } -``` +{{< / highlight >}} This query returns a list of all the available types (truncated here for brevity): -```json +{{< highlight json >}} { "data": { "__schema": { @@ -197,7 +197,7 @@ This query returns a list of all the available types (truncated here for brevity } } } -``` +{{< / highlight >}} ## Get a Deployment Config by name and namespace @@ -208,7 +208,7 @@ Once the desired data type discovered, you can use it directly. **Query:** -```graphql +{{< highlight graphql >}} query getDeploymentConfigByNameAndNamespace { comGithubOpenshiftApiAppsV1DeploymentConfig(name: "qlkube", namespace: "qlkube") { metadata { @@ -220,11 +220,11 @@ query getDeploymentConfigByNameAndNamespace { } } } -``` +{{< / highlight >}} **Reponse:** -```json +{{< highlight json >}} { "data": { "comGithubOpenshiftApiAppsV1DeploymentConfig": { @@ -238,7 +238,7 @@ query getDeploymentConfigByNameAndNamespace { } } } -``` +{{< / highlight >}} ## Get routes by hostname and namespace @@ -246,7 +246,7 @@ This query use a `fieldSelector` on the `host` field in the `spec` section and u **Query:** -```graphql +{{< highlight graphql >}} query getRouteByHostnameAndNamespace { routes: comGithubOpenshiftApiRouteV1RouteList(namespace: "qlkube" fieldSelector: "spec.host=qlkube-qlkube.app.itix.fr") { items { @@ -264,11 +264,11 @@ query getRouteByHostnameAndNamespace { } } } -``` +{{< / highlight >}} **Reponse:** -```json +{{< highlight json >}} { "data": { "routes": { @@ -294,13 +294,13 @@ query getRouteByHostnameAndNamespace { } } } -``` +{{< / highlight >}} ## Sending your GraphQL request from curl Once your GraphQL queries refined in the GraphQL Explorer, you can send them directly using curl or any HTTP client. -```sh +{{< highlight sh >}} export GLKUBE_HOSTNAME=$(oc get route qlkube -o go-template --template="{{.spec.host}}") cat <}} ## Advanced use-cases diff --git a/themes/cocoa b/themes/cocoa index 0cd0def..119b88c 160000 --- a/themes/cocoa +++ b/themes/cocoa @@ -1 +1 @@ -Subproject commit 0cd0defed65fa7f4de8c81b7d1eb4fd92b302d1f +Subproject commit 119b88c0f33b5cf23ad894df02ca70a67e39cebc