Skip to content

Commit

Permalink
unified namespace variable naming
Browse files Browse the repository at this point in the history
  • Loading branch information
a-thaler committed Oct 27, 2023
1 parent 3a965b3 commit fdf9721
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 126 deletions.
8 changes: 4 additions & 4 deletions event-email-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ This example illustrates how to write a service in `NodeJS` that listens for Eve

1. Export your Namespace as a variable by replacing the **{namespace}** placeholder in the following command and running it:
```bash
export KYMA_EXAMPLE_NS="{namespace}"
export K8S_NAMESPACE="{namespace}"
```

2. Deploy the service:
```bash
kubectl apply -f deployment -n $KYMA_EXAMPLE_NS
kubectl apply -f deployment -n $K8S_NAMESPACE
```

3. Expose the service endpoint:
```bash
kubectl port-forward -n $KYMA_EXAMPLE_NS $(kubectl get pod -n $KYMA_EXAMPLE_NS -l example=event-email-service | grep event-email-service | awk '{print $1}') 3000
kubectl port-forward -n $K8S_NAMESPACE $(kubectl get pod -n $K8S_NAMESPACE -l example=event-email-service | grep event-email-service | awk '{print $1}') 3000
```

### Test the service
Expand All @@ -56,5 +56,5 @@ After sending the Event, you should see a log entry either in your terminal (if
Clean all deployed example resources from Kyma with the following command:
```bash
kubectl delete all -l example=event-email-service -n $KYMA_EXAMPLE_NS
kubectl delete all -l example=event-email-service -n $K8S_NAMESPACE
```
24 changes: 12 additions & 12 deletions gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ There are additional prerequisites to exposing a service manually using kubectl:
1. Export your Namespace as a variable. Replace the `{namespace}` placeholder in the following command and run it:

```bash
export KYMA_EXAMPLE_NS="{namespace}"
export K8S_NAMESPACE="{namespace}"
```

2. Export your Kyma domain as a variable. Replace the `{domain}` placeholder in the following command and run it:
Expand All @@ -129,15 +129,15 @@ There are additional prerequisites to exposing a service manually using kubectl:
3. Apply the `deployment.yaml` file from the `service` directory in this example.

```bash
kubectl apply -f ./service/deployment.yaml -n $KYMA_EXAMPLE_NS
kubectl apply -f ./service/deployment.yaml -n $K8S_NAMESPACE
```

#### Expose a service without authentication

Run this command to create an API Rule:

```bash
kubectl apply -f ./service/api-without-auth.yaml -n $KYMA_EXAMPLE_NS
kubectl apply -f ./service/api-without-auth.yaml -n $K8S_NAMESPACE
```

#### Test the API Rules without authentication
Expand All @@ -163,7 +163,7 @@ metadata:
labels:
example: gateway-service
name: http-db-service
namespace: $KYMA_EXAMPLE_NS
namespace: $K8S_NAMESPACE
spec:
gateway: kyma-gateway.kyma-system.svc.cluster.local
rules:
Expand All @@ -190,7 +190,7 @@ EOF
You can also manually adjust the `https://dex.kyma.local` domain in the `trusted_issuers` section of the `api-with-jwt.yaml` file to fit your setup. After adjusting the domain, run:

```bash
kubectl apply -f ./service/api-with-jwt.yaml -n $KYMA_EXAMPLE_NS
kubectl apply -f ./service/api-with-jwt.yaml -n $K8S_NAMESPACE
```

#### Test the APIs with JWT authentication
Expand All @@ -211,15 +211,15 @@ curl -ik https://http-db-service.$KYMA_EXAMPLE_DOMAIN/orders -H 'Authorization:

Create an API Rule with the OAuth2 authentication settings:
```bash
kubectl apply -f ./service/api-with-oauth2.yaml -n $KYMA_EXAMPLE_NS
kubectl apply -f ./service/api-with-oauth2.yaml -n $K8S_NAMESPACE
```

#### Fetch the OAuth2 token

1. Create an OAuth2 client:

```bash
kubectl apply -f ./service/oauth2client.yaml -n $KYMA_EXAMPLE_NS
kubectl apply -f ./service/oauth2client.yaml -n $K8S_NAMESPACE
```

2. Fetch the access token with the required scopes. The access token in the response is referred to as the **\{oauth2-token\}**. Run:
Expand All @@ -245,9 +245,9 @@ curl -ik https://http-db-service.$KYMA_EXAMPLE_DOMAIN/orders -H 'Authorization:
Run the following command to completely remove the example and all its resources from the cluster:

```bash
kubectl delete all -l example=gateway-service -n $KYMA_EXAMPLE_NS
kubectl delete apirules.gateway.kyma-project.io -l example=gateway-service -n $KYMA_EXAMPLE_NS
kubectl delete oauth2clients.hydra.ory.sh -l example=gateway-service -n $KYMA_EXAMPLE_NS
kubectl delete all -l example=gateway-service -n $K8S_NAMESPACE
kubectl delete apirules.gateway.kyma-project.io -l example=gateway-service -n $K8S_NAMESPACE
kubectl delete oauth2clients.hydra.ory.sh -l example=gateway-service -n $K8S_NAMESPACE
```

## Troubleshooting
Expand All @@ -257,7 +257,7 @@ kubectl delete oauth2clients.hydra.ory.sh -l example=gateway-service -n $KYMA_EX
**No healthy upstream:** Check if the Pod you created is running. Run:

```bash
kubectl get pods -n $KYMA_EXAMPLE_NS
kubectl get pods -n $K8S_NAMESPACE
```

Wait until all containers of the Pod are running.
Expand All @@ -267,7 +267,7 @@ Wait until all containers of the Pod are running.
**Upstream connect error or disconnect/reset before headers:** Check if the Pod you created has the istio-proxy container injected. Run this command:

```bash
kubectl get pods -l example=gateway-service -n $KYMA_EXAMPLE_NS -o json | jq '.items[].spec.containers[].name'
kubectl get pods -l example=gateway-service -n $K8S_NAMESPACE -o json | jq '.items[].spec.containers[].name'
```

One of the returned strings should be the istio-proxy. If there is no such string, the Namespace probably does not have Istio injection enabled. For more information, read the document about the [sidecar proxy injection](https://kyma-project.io/#/04-operation-guides/operations/smsh-01-istio-enable-sidecar-injection).
8 changes: 4 additions & 4 deletions http-db-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ Run the following commands to deploy the published service to Kyma:
1. Export your Namespace as variable by replacing the `{namespace}` placeholder in the following command and running it:

```bash
export KYMA_EXAMPLE_NS="{namespace}"
export K8S_NAMESPACE="{namespace}"
```
2. Deploy the service:
```bash
kubectl create namespace $KYMA_EXAMPLE_NS
kubectl apply -f deployment/deployment.yaml -n $KYMA_EXAMPLE_NS
kubectl create namespace $K8S_NAMESPACE
kubectl apply -f deployment/deployment.yaml -n $K8S_NAMESPACE
```

### MSSQL Database tests
Expand All @@ -58,5 +58,5 @@ The command runs the specific unit tests for MSSQL databases with the environmen
Run the following command to completely remove the example and all its resources from the cluster:

```bash
kubectl delete all -l example=http-db-service -n $KYMA_EXAMPLE_NS
kubectl delete all -l example=http-db-service -n $K8S_NAMESPACE
```
26 changes: 13 additions & 13 deletions jaeger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The following instructions outline how to use [`Jaeger`](https://github.com/jaeg
1. Export your Namespace as a variable. Replace the `{namespace}` placeholder in the following command and run it:

```bash
export KYMA_NS="{namespace}"
export K8S_NAMESPACE="{namespace}"
```

1. Export the Helm release name that you want to use. The release name must be unique for the chosen Namespace. Be aware that all resources in the cluster will be prefixed with that name. Run the following command:
Expand All @@ -39,7 +39,7 @@ The following instructions outline how to use [`Jaeger`](https://github.com/jaeg

Run the Helm upgrade command, which installs the chart if not present yet.
```bash
helm upgrade --install --create-namespace -n $KYMA_NS $HELM_JAEGER_RELEASE jaegertracing/jaeger -f https://raw.githubusercontent.com/kyma-project/examples/main/jaeger/values.yaml
helm upgrade --install --create-namespace -n $K8S_NAMESPACE $HELM_JAEGER_RELEASE jaegertracing/jaeger -f https://raw.githubusercontent.com/kyma-project/examples/main/jaeger/values.yaml
```

You can either use the [`values.yaml`](./values.yaml) provided in this `jaeger` folder, which contains customized settings deviating from the default settings, or create your own `values.yaml` file.
Expand All @@ -48,15 +48,15 @@ You can either use the [`values.yaml`](./values.yaml) provided in this `jaeger`

Check if the `jaeger` Pod was successfully created in the Namespace and is in the `Running` state:
```bash
kubectl -n $KYMA_NS rollout status deploy $HELM_JAEGER_RELEASE
kubectl -n $K8S_NAMESPACE rollout status deploy $HELM_JAEGER_RELEASE
```

### Activate a TracePipeline

To configure the Kyma trace collector with the deployed Jaeger instance as the backend. To create a new [TracePipeline](https://kyma-project.io/#/telemetry-manager/user/03-traces),
execute the following command:
```bash
cat <<EOF | kubectl -n $KYMA_NS apply -f -
cat <<EOF | kubectl -n $K8S_NAMESPACE apply -f -
apiVersion: telemetry.kyma-project.io/v1alpha1
kind: TracePipeline
metadata:
Expand All @@ -66,7 +66,7 @@ execute the following command:
otlp:
protocol: http
endpoint:
value: http://$HELM_JAEGER_RELEASE-collector.$KYMA_NS.svc.cluster.local:4318
value: http://$HELM_JAEGER_RELEASE-collector.$K8S_NAMESPACE.svc.cluster.local:4318
EOF
```
Expand All @@ -93,7 +93,7 @@ EOF
To access Jaeger using port forwarding, run:
```bash
kubectl -n $KYMA_NS port-forward svc/$HELM_JAEGER_RELEASE-query 16686
kubectl -n $K8S_NAMESPACE port-forward svc/$HELM_JAEGER_RELEASE-query 16686
```
Open the Jaeger UI in your browser under `http://localhost:16686`.
Expand All @@ -109,7 +109,7 @@ To see distributed traces visualized in Jaeger, follow the instructions in [`tra
Jaeger can be provided as a data source integrated into Grafana. For example, it can be part of a Grafana installation as described in the [Prometheus tutorial](./../prometheus/README.md). To have a Jaeger data source as part of the Grafana installation, deploy a Grafana data source in the following way:
```bash
cat <<EOF | kubectl -n $KYMA_NS apply -f -
cat <<EOF | kubectl -n $K8S_NAMESPACE apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -123,7 +123,7 @@ data:
- name: Jaeger-Tracing
type: jaeger
access: proxy
url: http://$HELM_JAEGER_RELEASE-query.$KYMA_NS:16686
url: http://$HELM_JAEGER_RELEASE-query.$K8S_NAMESPACE:16686
editable: true
EOF
```
Expand All @@ -139,7 +139,7 @@ Jaeger does not provide authentication mechanisms by itself. To secure Jaeger, f
To expose Jaeger using Kyma API Gateway, create the following APIRule:
```bash
cat <<EOF | kubectl -n $KYMA_NS apply -f -
cat <<EOF | kubectl -n $K8S_NAMESPACE apply -f -
apiVersion: gateway.kyma-project.io/v1beta1
kind: APIRule
metadata:
Expand All @@ -162,7 +162,7 @@ EOF
Get the public URL of your Jaeger instance:
```bash
kubectl -n $KYMA_NS get vs -l apirule.gateway.kyma-project.io/v1beta1=jaeger.$KYMA_NS -ojsonpath='{.items[*].spec.hosts[*]}'
kubectl -n $K8S_NAMESPACE get vs -l apirule.gateway.kyma-project.io/v1beta1=jaeger.$K8S_NAMESPACE -ojsonpath='{.items[*].spec.hosts[*]}'
```
## Cleanup
Expand All @@ -172,10 +172,10 @@ When you're done, remove the example and all its resources from the cluster.
1. Remove the stack by calling Helm:
```bash
helm delete -n $KYMA_NS $HELM_JAEGER_RELEASE
helm delete -n $K8S_NAMESPACE $HELM_JAEGER_RELEASE
```
2. If you created the `$KYMA_NS` Namespace specifically for this tutorial, remove the Namespace:
2. If you created the `$K8S_NAMESPACE` Namespace specifically for this tutorial, remove the Namespace:
```bash
kubectl delete namespace $KYMA_NS
kubectl delete namespace $K8S_NAMESPACE
```
24 changes: 12 additions & 12 deletions kiali/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The following instructions outline how to install [`Kiali`](https://github.com/k
1. Export your Namespace as a variable. Replace the `{namespace}` placeholder in the following command and run it:

```bash
export KYMA_NS="{namespace}"
export K8S_NAMESPACE="{namespace}"
```

1. Export the Helm release name that you want to use. The release name must be unique for the chosen Namespace. Be aware that all resources in the cluster will be prefixed with that name. Run the following command:
Expand All @@ -39,8 +39,8 @@ The following instructions outline how to install [`Kiali`](https://github.com/k
Run the Helm upgrade command, which installs the chart if not present yet.
```bash
export PROM_SERVICE_NAME=$(kubectl -n ${KYMA_NS} get service -l app=kube-prometheus-stack-prometheus -ojsonpath='{.items[*].metadata.name}')
helm upgrade --install --create-namespace -n $KYMA_NS $HELM_KIALI_RELEASE kiali/kiali-operator -f https://raw.githubusercontent.com/kyma-project/examples/main/kiali/values.yaml --set cr.spec.external_services.prometheus.url=http://$PROM_SERVICE_NAME.$KYMA_NS:9090
export PROM_SERVICE_NAME=$(kubectl -n ${K8S_NAMESPACE} get service -l app=kube-prometheus-stack-prometheus -ojsonpath='{.items[*].metadata.name}')
helm upgrade --install --create-namespace -n $K8S_NAMESPACE $HELM_KIALI_RELEASE kiali/kiali-operator -f https://raw.githubusercontent.com/kyma-project/examples/main/kiali/values.yaml --set cr.spec.external_services.prometheus.url=http://$PROM_SERVICE_NAME.$K8S_NAMESPACE:9090
```
You can either use the [`values.yaml`](./values.yaml) provided in this `kiali` folder, which contains customized settings deviating from the default settings, or create your own `values.yaml` file.
Expand All @@ -49,26 +49,26 @@ You can either use the [`values.yaml`](./values.yaml) provided in this `kiali` f
Check that the `kiali-operator` and `kiali-server` Pods have been created in the Namespace and are in the `Running` state:
```bash
kubectl -n $KYMA_NS rollout status deploy $HELM_KIALI_RELEASE-kiali-operator && kubectl -n $KYMA_NS rollout status deploy kiali-server
kubectl -n $K8S_NAMESPACE rollout status deploy $HELM_KIALI_RELEASE-kiali-operator && kubectl -n $K8S_NAMESPACE rollout status deploy kiali-server
```
### Access Kiali
To access Kiali, either use kubectl port forwarding, or expose it using the Kyma Ingress Gateway.
* To access Kiali using port forwarding, run:
```bash
kubectl -n $KYMA_NS port-forward svc/kiali-server 20001
kubectl -n $K8S_NAMESPACE port-forward svc/kiali-server 20001
```
Open Kiali in your browser under `http://localhost:20001` and log in with a [Kubernetes service account token](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#service-account-tokens), for instance, from your kubeconfig file.
* To expose Kiali using the Kyma API Gateway, create an APIRule:
```bash
kubectl -n $KYMA_NS apply -f https://raw.githubusercontent.com/kyma-project/examples/main/kiali/apirule.yaml
kubectl -n $K8S_NAMESPACE apply -f https://raw.githubusercontent.com/kyma-project/examples/main/kiali/apirule.yaml
```
Get the public URL of your Kiali server:
```bash
kubectl -n $KYMA_NS get vs -l apirule.gateway.kyma-project.io/v1beta1=kiali.$KYMA_NS -ojsonpath='{.items[*].spec.hosts[*]}'
kubectl -n $K8S_NAMESPACE get vs -l apirule.gateway.kyma-project.io/v1beta1=kiali.$K8S_NAMESPACE -ojsonpath='{.items[*].spec.hosts[*]}'
```
### Deploy a custom workload and invoke
Expand All @@ -95,7 +95,7 @@ Kiali supports different authentication strategies. The default authentication s
* For Kiali access by port forwarding, you need no additional authentication, and you can activate the [anonymous strategy](https://kiali.io/docs/configuration/authentication/anonymous/):
```bash
helm upgrade --install --create-namespace -n $KYMA_NS $HELM_KIALI_RELEASE kiali/kiali-operator --set cr.spec.auth.strategy=anonymous -f https://raw.githubusercontent.com/kyma-project/examples/main/kiali/values.yaml
helm upgrade --install --create-namespace -n $K8S_NAMESPACE $HELM_KIALI_RELEASE kiali/kiali-operator --set cr.spec.auth.strategy=anonymous -f https://raw.githubusercontent.com/kyma-project/examples/main/kiali/values.yaml
```
* When exposing the Kiali server over the ingress gateway, we recommend to use an external identity provider compatible with OpenID Connect (OIDC). Find the required settings at [Kiali: OpenID Connect strategy](https://kiali.io/docs/configuration/authentication/openid/).
Expand All @@ -106,11 +106,11 @@ When you're done, you can remove the example and all its resources from the clus
1. Remove the stack by calling Helm:

```bash
helm delete -n $KYMA_NS $HELM_KIALI_RELEASE
kubectl -n $KYMA_NS delete -f https://raw.githubusercontent.com/kyma-project/examples/main/kiali/apirule.yaml
helm delete -n $K8S_NAMESPACE $HELM_KIALI_RELEASE
kubectl -n $K8S_NAMESPACE delete -f https://raw.githubusercontent.com/kyma-project/examples/main/kiali/apirule.yaml
```

2. If you created the `$KYMA_NS` Namespace specifically for this tutorial, remove the Namespace:
2. If you created the `$K8S_NAMESPACE` Namespace specifically for this tutorial, remove the Namespace:
```bash
kubectl delete namespace $KYMA_NS
kubectl delete namespace $K8S_NAMESPACE
```
Loading

0 comments on commit fdf9721

Please sign in to comment.