<commit_before>#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

{{- if .Values.extra.proxy }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}"
  namespace: {{ .Values.namespace }}
  labels:
    app: {{ template "pulsar.name" . }}
    chart: {{ template "pulsar.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
    component: {{ .Values.proxy.component }}
    cluster: {{ template "pulsar.fullname" . }}
spec:
  replicas: {{ .Values.proxy.replicaCount }}
  selector:
    matchLabels:
      app: {{ template "pulsar.name" . }}
      release: {{ .Release.Name }}
      component: {{ .Values.proxy.component }}
  template:
    metadata:
      labels:
        app: {{ template "pulsar.name" . }}
        release: {{ .Release.Name }}
        component: {{ .Values.proxy.component }}
        cluster: {{ template "pulsar.fullname" . }}
      annotations:
{{ toYaml .Values.proxy.annotations | indent 8 }}
    spec:
    {{- if .Values.proxy.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.proxy.nodeSelector | indent 8 }}
    {{- end }}
    {{- if .Values.proxy.tolerations }}
      tolerations:
{{ toYaml .Values.proxy.tolerations | indent 8 }}
    {{- end }}
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: "app"
                operator: In
                values:
                - "{{ template "pulsar.name" . }}"
              - key: "release"
                operator: In
                values:
                - {{ .Release.Name }}
              - key: "component"
                operator: In
                values:
                - {{ .Values.proxy.component }}
            topologyKey: "kubernetes.io/hostname"
      terminationGracePeriodSeconds: {{ .Values.proxy.gracePeriod }}
      initContainers:
      # This init container will wait for zookeeper to be ready before
      # deploying the bookies
      - name: wait-zookeeper-ready
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        command: ["sh", "-c"]
        args:
          - >-
            until bin/pulsar zookeeper-shell -server {{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }} ls /admin/clusters/{{ template "pulsar.fullname" . }}; do
              sleep 3;
            done;
      containers:
      - name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}"
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
      {{- if .Values.proxy.resources }}
        resources:
{{ toYaml .Values.proxy.resources | indent 10 }}
      {{- end }}
        command: ["sh", "-c"]
        args:
        - >
          bin/apply-config-from-env.py conf/proxy.conf &&
          bin/apply-config-from-env.py conf/pulsar_env.sh &&
          bin/pulsar proxy
        ports:
        - name: http
          containerPort: 8080
        envFrom:
        - configMapRef:
            name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}"
{{- end }}
<commit_msg>[Issue-5994]: Start proxy pods when at least one broker pod is running (#6158)<commit_after>#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

{{- if .Values.extra.proxy }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}"
  namespace: {{ .Values.namespace }}
  labels:
    app: {{ template "pulsar.name" . }}
    chart: {{ template "pulsar.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
    component: {{ .Values.proxy.component }}
    cluster: {{ template "pulsar.fullname" . }}
spec:
  replicas: {{ .Values.proxy.replicaCount }}
  selector:
    matchLabels:
      app: {{ template "pulsar.name" . }}
      release: {{ .Release.Name }}
      component: {{ .Values.proxy.component }}
  template:
    metadata:
      labels:
        app: {{ template "pulsar.name" . }}
        release: {{ .Release.Name }}
        component: {{ .Values.proxy.component }}
        cluster: {{ template "pulsar.fullname" . }}
      annotations:
{{ toYaml .Values.proxy.annotations | indent 8 }}
    spec:
    {{- if .Values.proxy.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.proxy.nodeSelector | indent 8 }}
    {{- end }}
    {{- if .Values.proxy.tolerations }}
      tolerations:
{{ toYaml .Values.proxy.tolerations | indent 8 }}
    {{- end }}
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: "app"
                operator: In
                values:
                - "{{ template "pulsar.name" . }}"
              - key: "release"
                operator: In
                values:
                - {{ .Release.Name }}
              - key: "component"
                operator: In
                values:
                - {{ .Values.proxy.component }}
            topologyKey: "kubernetes.io/hostname"
      terminationGracePeriodSeconds: {{ .Values.proxy.gracePeriod }}
      initContainers:
      # This init container will wait for zookeeper to be ready before
      # deploying the proxies
      - name: wait-zookeeper-ready
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        command: ["sh", "-c"]
        args:
          - >-
            until bin/pulsar zookeeper-shell -server {{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }} ls /admin/clusters/{{ template "pulsar.fullname" . }}; do
              sleep 3;
            done;
      # This init container will wait for at least one broker to be ready before
      # deploying the proxy
      - name: wait-broker-ready
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        command: ["bash", "-c"]
        args:
          - >-
            for i in {0..{{ .Values.broker.replicaCount }}}; do
              brokerServiceNumber="$(nslookup -timeout=10 {{ template "pulsar.fullname" . }}-{{ .Values.broker.component }} | grep Name | wc -l)"
              if [[ ${brokerServiceNumber} -ge 1 ]]; then
                break
              fi
              sleep 30;
            done;
      containers:
      - name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}"
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
      {{- if .Values.proxy.resources }}
        resources:
{{ toYaml .Values.proxy.resources | indent 10 }}
      {{- end }}
        command: ["sh", "-c"]
        args:
        - >
          bin/apply-config-from-env.py conf/proxy.conf &&
          bin/apply-config-from-env.py conf/pulsar_env.sh &&
          bin/pulsar proxy
        ports:
        - name: http
          containerPort: 8080
        envFrom:
        - configMapRef:
            name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}"
{{- end }}

{'fraction_non_alphanumeric': 0.1338816541009824, 'fraction_numerical': 0.005026273703449852, 'mean_word_length': 2.118988243676523, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6889004', 'n_tokens_mistral': 2552, 'n_tokens_neox': 2478, 'n_words': 661}