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"]
path = themes/cocoa
url = https://github.com/nishanths/cocoa-hugo-theme.git
branch = v0.6.0
url = https://github.com/nmasse-itix/cocoa-hugo-theme.git
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
```
## 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é"
author = "Nicolas Massé"
theme = "cocoa"
pygmentsUseClasses = true
pygmentsCodefences = true
[taxonomies]
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.
**production.lua:**
```lua
{{< highlight lua "hl_lines=8-14" >}}
return {
master_process = 'on',
lua_code_cache = 'on',
@ -35,10 +35,10 @@ return {
'apicast.policy.nginx_metrics'
}),
}
```
{{< / 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 >}}

4
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

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:
```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

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:
```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 <<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
```
{{< / highlight >}}
## Advanced use-cases

4
netlify.toml

@ -1,6 +1,6 @@
[build]
publish = "public"
command = "hugo"
command = "hugo gen chromastyles --style=perldoc > static/css/chroma.css && hugo"
[build.environment] # Global
HUGO_VERSION = "0.42"
@ -9,7 +9,7 @@ HUGO_VERSION = "0.42"
HUGO_VERSION = "0.42"
[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]
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