Browse Source

Merge pull request #6 from nmasse-itix/2019-09-11-update

implement chroma highlighting
itix-theme
Nicolas Massé 6 years ago
committed by GitHub
parent
commit
84129fd1a2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .gitmodules
  2. 6
      README.md
  3. 2
      config.toml
  4. 12
      content/blog/enable-global-policies-apicast.md
  5. 4
      content/blog/is-my-ntp-daemon-working.md
  6. 6
      content/blog/use-ansible-to-manage-the-qos-of-your-openshift-workload.md
  7. 64
      content/blog/use-qlkube-to-query-the-kubernetes-api.md
  8. 4
      netlify.toml
  9. 1
      static/css/.gitignore
  10. 2
      themes/cocoa

4
.gitmodules

@ -1,4 +1,4 @@
[submodule "themes/cocoa"] [submodule "themes/cocoa"]
path = themes/cocoa path = themes/cocoa
url = https://github.com/nishanths/cocoa-hugo-theme.git url = https://github.com/nmasse-itix/cocoa-hugo-theme.git
branch = v0.6.0 branch = nmasse-itix

6
README.md

@ -61,3 +61,9 @@ You can update a theme to the latest version by executing the following command
git submodule update --rebase --remote git submodule update --rebase --remote
``` ```
## How to change the Chroma style for syntax highlighting
```sh
mkdir -p static/css
hugo gen chromastyles --style=perldoc > static/css/chroma.css
```

2
config.toml

@ -3,6 +3,8 @@ languageCode = "en-us"
title = "Nicolas Massé" title = "Nicolas Massé"
author = "Nicolas Massé" author = "Nicolas Massé"
theme = "cocoa" theme = "cocoa"
pygmentsUseClasses = true
pygmentsCodefences = true
[taxonomies] [taxonomies]
opensource = "opensource" opensource = "opensource"

12
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. 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:** **production.lua:**
```lua {{< highlight lua "hl_lines=8-14" >}}
return { return {
master_process = 'on', master_process = 'on',
lua_code_cache = 'on', lua_code_cache = 'on',
@ -35,10 +35,10 @@ return {
'apicast.policy.nginx_metrics' 'apicast.policy.nginx_metrics'
}), }),
} }
``` {{< / highlight >}}
**staging.lua:** **staging.lua:**
```lua {{< highlight lua "hl_lines=7-13" >}}
return { return {
master_process = 'on', master_process = 'on',
lua_code_cache = 'on', lua_code_cache = 'on',
@ -53,12 +53,12 @@ return {
'apicast.policy.nginx_metrics' 'apicast.policy.nginx_metrics'
}), }),
} }
``` {{< / highlight >}}
Then, create a ConfigMap from those two files and mount it in `/opt/app-root/src/config`: 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 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-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 oc set volume dc/apicast-staging --add --name=apicast-cors -t configmap --configmap-name=apicast-cors -m /opt/app-root/src/config
``` {{< / highlight >}}

4
content/blog/is-my-ntp-daemon-working.md

@ -19,7 +19,7 @@ time.
First, make sure your NTP daemon is started: First, make sure your NTP daemon is started:
```sh ```raw
$ sudo systemctl status ntpd $ sudo systemctl status ntpd
● ntpd.service - Network Time Service ● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled) 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: Then, run the ntpdate command:
```sh ```raw
$ sudo ntpdate -q 0.rhel.pool.ntp.org $ sudo ntpdate -q 0.rhel.pool.ntp.org
server 91.121.88.161, stratum 2, offset -0.000393, delay 0.02974 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 server 129.250.35.251, stratum 2, offset 0.004071, delay 0.02733

6
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: This first task has been accomplished very easily with a first playbook:
```yaml ```raw
- name: List all DeploymentConfig having a request or limit set - name: List all DeploymentConfig having a request or limit set
hosts: localhost hosts: localhost
gather_facts: no 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 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. 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 - name: Change the QoS class of commodity projects
hosts: localhost hosts: localhost
gather_facts: no gather_facts: no
@ -186,7 +186,7 @@ blacklist of critical namespaces that should not be touched.
loop_control: loop_control:
loop_var: obj loop_var: obj
when: obj.namespace not in namespace_blacklist when: obj.namespace not in namespace_blacklist
``` {{< / highlight >}}
You can find the complete playbook [here](change-qos.yaml). Of course, it is 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 very rough and would need to more work to be used on a daily basis but for a

64
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: To install QLKube in OpenShift, use the NodeJS Source-to-Image builder:
```sh {{< highlight sh >}}
oc new-project qlkube --display-name=QLKube oc new-project qlkube --display-name=QLKube
oc new-app nodejs~https://github.com/qlkube/qlkube.git --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: Disable TLS certificate validation to accommodate your self-signed certificates:
```sh {{< highlight sh >}}
oc set env dc/qlkube NODE_TLS_REJECT_UNAUTHORIZED=0 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): 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 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: 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 oc adm policy add-role-to-user view -z default
``` {{< / highlight >}}
Once deployed, open the QLKube URL in your web browser: 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}}") open $(oc get route qlkube -o go-template --template="http://{{.spec.host}}")
``` {{< / highlight >}}
You can try the following queries in the GraphQL explorer. 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:** **Query:**
```graphql {{< highlight graphql >}}
query getAllPodsInCurrentNamespace { query getAllPodsInCurrentNamespace {
all(namespace: "qlkube") { all(namespace: "qlkube") {
pods { pods {
@ -67,11 +67,11 @@ query getAllPodsInCurrentNamespace {
} }
} }
} }
``` {{< / highlight >}}
**Response:** **Response:**
```json {{< highlight json >}}
{ {
"data": { "data": {
"all": { "all": {
@ -100,7 +100,7 @@ query getAllPodsInCurrentNamespace {
} }
} }
} }
``` {{< / highlight >}}
## Get a service by name ## 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:** **Query:**
```graphql {{< highlight graphql >}}
query getServiceByNameAndNamespace { query getServiceByNameAndNamespace {
all(namespace: "qlkube", fieldSelector: "metadata.name=qlkube") { all(namespace: "qlkube", fieldSelector: "metadata.name=qlkube") {
services { services {
@ -124,11 +124,11 @@ query getServiceByNameAndNamespace {
} }
} }
} }
``` {{< / highlight >}}
**Response:** **Response:**
```json {{< highlight json >}}
{ {
"data": { "data": {
"all": { "all": {
@ -148,14 +148,14 @@ query getServiceByNameAndNamespace {
} }
} }
} }
``` {{< / highlight >}}
## Type introspection ## Type introspection
Playing with the built-in types of GLKube is nice but you might soon be limited. 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: To discover all the available types, run this query:
```graphql {{< highlight graphql >}}
{ {
__schema { __schema {
types { 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): This query returns a list of all the available types (truncated here for brevity):
```json {{< highlight json >}}
{ {
"data": { "data": {
"__schema": { "__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 ## Get a Deployment Config by name and namespace
@ -208,7 +208,7 @@ Once the desired data type discovered, you can use it directly.
**Query:** **Query:**
```graphql {{< highlight graphql >}}
query getDeploymentConfigByNameAndNamespace { query getDeploymentConfigByNameAndNamespace {
comGithubOpenshiftApiAppsV1DeploymentConfig(name: "qlkube", namespace: "qlkube") { comGithubOpenshiftApiAppsV1DeploymentConfig(name: "qlkube", namespace: "qlkube") {
metadata { metadata {
@ -220,11 +220,11 @@ query getDeploymentConfigByNameAndNamespace {
} }
} }
} }
``` {{< / highlight >}}
**Reponse:** **Reponse:**
```json {{< highlight json >}}
{ {
"data": { "data": {
"comGithubOpenshiftApiAppsV1DeploymentConfig": { "comGithubOpenshiftApiAppsV1DeploymentConfig": {
@ -238,7 +238,7 @@ query getDeploymentConfigByNameAndNamespace {
} }
} }
} }
``` {{< / highlight >}}
## Get routes by hostname and namespace ## 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:** **Query:**
```graphql {{< highlight graphql >}}
query getRouteByHostnameAndNamespace { query getRouteByHostnameAndNamespace {
routes: comGithubOpenshiftApiRouteV1RouteList(namespace: "qlkube" fieldSelector: "spec.host=qlkube-qlkube.app.itix.fr") { routes: comGithubOpenshiftApiRouteV1RouteList(namespace: "qlkube" fieldSelector: "spec.host=qlkube-qlkube.app.itix.fr") {
items { items {
@ -264,11 +264,11 @@ query getRouteByHostnameAndNamespace {
} }
} }
} }
``` {{< / highlight >}}
**Reponse:** **Reponse:**
```json {{< highlight json >}}
{ {
"data": { "data": {
"routes": { "routes": {
@ -294,13 +294,13 @@ query getRouteByHostnameAndNamespace {
} }
} }
} }
``` {{< / highlight >}}
## Sending your GraphQL request from curl ## 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. 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}}") export GLKUBE_HOSTNAME=$(oc get route qlkube -o go-template --template="{{.spec.host}}")
cat <<EOF | curl -XPOST "http://$GLKUBE_HOSTNAME/" -H "Content-Type: application/json" -d @- -s |jq . cat <<EOF | curl -XPOST "http://$GLKUBE_HOSTNAME/" -H "Content-Type: application/json" -d @- -s |jq .
@ -321,7 +321,7 @@ cat <<EOF | curl -XPOST "http://$GLKUBE_HOSTNAME/" -H "Content-Type: application
}" }"
} }
EOF EOF
``` {{< / highlight >}}
## Advanced use-cases ## Advanced use-cases

4
netlify.toml

@ -1,6 +1,6 @@
[build] [build]
publish = "public" publish = "public"
command = "hugo" command = "hugo gen chromastyles --style=perldoc > static/css/chroma.css && hugo"
[build.environment] # Global [build.environment] # Global
HUGO_VERSION = "0.42" HUGO_VERSION = "0.42"
@ -9,7 +9,7 @@ HUGO_VERSION = "0.42"
HUGO_VERSION = "0.42" HUGO_VERSION = "0.42"
[context.deploy-preview] [context.deploy-preview]
command = "hugo --buildDrafts --buildFuture --baseURL $DEPLOY_PRIME_URL" command = "hugo gen chromastyles --style=perldoc > static/css/chroma.css && hugo --buildDrafts --buildFuture --baseURL $DEPLOY_PRIME_URL"
[context.deploy-preview.environment] [context.deploy-preview.environment]
HUGO_ENABLEGITINFO = "true" HUGO_ENABLEGITINFO = "true"

1
static/css/.gitignore

@ -0,0 +1 @@
chroma.css

2
themes/cocoa

@ -1 +1 @@
Subproject commit 9592a80a742c54b6e4d43ab020552c863fc41bc0 Subproject commit 119b88c0f33b5cf23ad894df02ca70a67e39cebc
Loading…
Cancel
Save