Skip to content

Commit

Permalink
fix kubectl command
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdotcosta committed Apr 18, 2024
1 parent 3f5dfff commit 3d60c56
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions kind/kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -359,42 +359,42 @@ function delete_cri_resources(){
deploy_ingress_kourier() {
note "1" "Deploying KNative Ingress"
echo "Install the required custom resources of knative"
kubectl --kubeconfig ${KUBECONFIG_TGT} apply -f https://github.com/knative/serving/releases/download/knative-v${KNATIVE_VERSION}/serving-crds.yaml
${KC_CMD} apply -f https://github.com/knative/serving/releases/download/knative-v${KNATIVE_VERSION}/serving-crds.yaml

note "1" "Install the core components of Knative Serving"
kubectl --kubeconfig ${KUBECONFIG_TGT} apply -f https://github.com/knative/serving/releases/download/knative-v${KNATIVE_VERSION}/serving-core.yaml
kubectl --kubeconfig ${KUBECONFIG_TGT} -n knative-serving rollout status deployment activator
kubectl --kubeconfig ${KUBECONFIG_TGT} -n knative-serving rollout status deployment autoscaler
kubectl --kubeconfig ${KUBECONFIG_TGT} -n knative-serving rollout status deployment controller
kubectl --kubeconfig ${KUBECONFIG_TGT} -n knative-serving rollout status deployment domain-mapping
kubectl --kubeconfig ${KUBECONFIG_TGT} -n knative-serving rollout status deployment domainmapping-webhook
kubectl --kubeconfig ${KUBECONFIG_TGT} -n knative-serving rollout status deployment webhook
${KC_CMD} apply -f https://github.com/knative/serving/releases/download/knative-v${KNATIVE_VERSION}/serving-core.yaml
${KC_CMD} -n knative-serving rollout status deployment activator
${KC_CMD} -n knative-serving rollout status deployment autoscaler
${KC_CMD} -n knative-serving rollout status deployment controller
${KC_CMD} -n knative-serving rollout status deployment domain-mapping
${KC_CMD} -n knative-serving rollout status deployment domainmapping-webhook
${KC_CMD} -n knative-serving rollout status deployment webhook

note "1" "Install the Knative Kourier controller"
kubectl --kubeconfig ${KUBECONFIG_TGT} apply -f https://github.com/knative/net-kourier/releases/download/knative-v${KNATIVE_VERSION}/kourier.yaml
kubectl --kubeconfig ${KUBECONFIG_TGT} -n knative-serving rollout status deployment net-kourier-controller
kubectl --kubeconfig ${KUBECONFIG_TGT} -n kourier-system rollout status deployment 3scale-kourier-gateway
${KC_CMD} apply -f https://github.com/knative/net-kourier/releases/download/knative-v${KNATIVE_VERSION}/kourier.yaml
${KC_CMD} -n knative-serving rollout status deployment net-kourier-controller
${KC_CMD} -n kourier-system rollout status deployment 3scale-kourier-gateway

note "1" "Configure Knative Serving to use Kourier by default"
kubectl --kubeconfig ${KUBECONFIG_TGT} patch configmap/config-network \
${KC_CMD} patch configmap/config-network \
-n knative-serving \
--type merge \
-p '{"data":{"ingress-class":"kourier.ingress.networking.knative.dev"}}'

note "1" "Configure the Knative domain to: $SERVER_IP.nip.io"
KNATIVE_DOMAIN="${SERVER_IP}.nip.io"
kubectl --kubeconfig ${KUBECONFIG_TGT} patch configmap/config-domain \
${KC_CMD} patch configmap/config-domain \
-n knative-serving \
-p "{\"data\": {\"$KNATIVE_DOMAIN\": \"\"}}"

note "1" "Patching the kourier service to use the nodePort 31080 and type nodePort"
kubectl --kubeconfig ${KUBECONFIG_TGT} patch -n kourier-system svc kourier --type='json' -p="[{\"op\": \"replace\", \"path\": \"/spec/ports/0/nodePort\", \"value\": ${INGRESS_80_CONTAINER_PORT}}]"
kubectl --kubeconfig ${KUBECONFIG_TGT} patch -n kourier-system svc kourier --type='json' -p="[{\"op\": \"replace\", \"path\": \"/spec/ports/1/nodePort\", \"value\": ${INGRESS_443_CONTAINER_PORT}}]"
kubectl --kubeconfig ${KUBECONFIG_TGT} patch -n kourier-system svc kourier --type='json' -p='[{"op": "replace", "path": "/spec/type", "value": "NodePort"}]'
${KC_CMD} patch -n kourier-system svc kourier --type='json' -p="[{\"op\": \"replace\", \"path\": \"/spec/ports/0/nodePort\", \"value\": ${INGRESS_80_CONTAINER_PORT}}]"
${KC_CMD} patch -n kourier-system svc kourier --type='json' -p="[{\"op\": \"replace\", \"path\": \"/spec/ports/1/nodePort\", \"value\": ${INGRESS_443_CONTAINER_PORT}}]"
${KC_CMD} patch -n kourier-system svc kourier --type='json' -p='[{"op": "replace", "path": "/spec/type", "value": "NodePort"}]'

note "0" "####### TO TEST ########"
note "0" "Execute the following commands: "
knCmd="cat <<-EOF | kubectl --kubeconfig ${KUBECONFIG_TGT} apply -f -
knCmd="cat <<-EOF | ${KC_CMD} apply -f -
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
Expand Down Expand Up @@ -440,14 +440,7 @@ deploy_ingress_nginx() {
function configure_registry_on_kind() {
# Document the local registry
# https://github.com/kubernetes/enhancements/tree/master/keps/sig-cluster-lifecycle/generic/1755-communicating-a-local-registry
if
if [ ${KUBECONFIG_GEN} == "n" ]; then
KC_REG_CMD="kubectl apply -f"
else
KC_REG_CMD="kubectl --kubeconfig ${KUBECONFIG_TGT} apply -f"
fi
note "2" "KC_REG_CMD: ${KC_REG_CMD}"
cat <<EOF | ${KC_REG_CMD} -
cat <<EOF | ${KC_CMD} apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down Expand Up @@ -768,6 +761,11 @@ function define_runtime_commands() {
HOST_80_PORT=80
HOST_443_PORT=443
fi
KC_CMD="kubectl "
if [ ${KUBECONFIG_GEN} == "y" ]; then
KC_CMD+=" --kubeconfig ${KUBECONFIG_TGT} "
fi
note "2" "KC_CMD: ${KC_CMD}"
}

function check_os() {
Expand Down

0 comments on commit 3d60c56

Please sign in to comment.